diff --git a/resource-manager/containerservice/2025-02-01/agentpools/README.md b/resource-manager/containerservice/2025-02-01/agentpools/README.md new file mode 100644 index 00000000000..c19af3fdbad --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/README.md @@ -0,0 +1,156 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/agentpools` Documentation + +The `agentpools` SDK allows for interaction with Azure Resource Manager `containerservice` (API Version `2025-02-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/containerservice/2025-02-01/agentpools" +``` + + +### Client Initialization + +```go +client := agentpools.NewAgentPoolsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AgentPoolsClient.AbortLatestOperation` + +```go +ctx := context.TODO() +id := agentpools.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "agentPoolName") + +if err := client.AbortLatestOperationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AgentPoolsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := agentpools.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "agentPoolName") + +payload := agentpools.AgentPool{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, agentpools.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `AgentPoolsClient.Delete` + +```go +ctx := context.TODO() +id := agentpools.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "agentPoolName") + +if err := client.DeleteThenPoll(ctx, id, agentpools.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `AgentPoolsClient.DeleteMachines` + +```go +ctx := context.TODO() +id := agentpools.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "agentPoolName") + +payload := agentpools.AgentPoolDeleteMachinesParameter{ + // ... +} + + +if err := client.DeleteMachinesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AgentPoolsClient.Get` + +```go +ctx := context.TODO() +id := agentpools.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "agentPoolName") + +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: `AgentPoolsClient.GetAvailableAgentPoolVersions` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +read, err := client.GetAvailableAgentPoolVersions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AgentPoolsClient.GetUpgradeProfile` + +```go +ctx := context.TODO() +id := agentpools.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "agentPoolName") + +read, err := client.GetUpgradeProfile(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AgentPoolsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +// 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: `AgentPoolsClient.UpgradeNodeImageVersion` + +```go +ctx := context.TODO() +id := agentpools.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "agentPoolName") + +if err := client.UpgradeNodeImageVersionThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/containerservice/2025-02-01/agentpools/client.go b/resource-manager/containerservice/2025-02-01/agentpools/client.go new file mode 100644 index 00000000000..c46e6323495 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/client.go @@ -0,0 +1,26 @@ +package agentpools + +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 AgentPoolsClient struct { + Client *resourcemanager.Client +} + +func NewAgentPoolsClientWithBaseURI(sdkApi sdkEnv.Api) (*AgentPoolsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "agentpools", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AgentPoolsClient: %+v", err) + } + + return &AgentPoolsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/constants.go b/resource-manager/containerservice/2025-02-01/agentpools/constants.go new file mode 100644 index 00000000000..e7a9a569340 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/constants.go @@ -0,0 +1,602 @@ +package agentpools + +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 AgentPoolMode string + +const ( + AgentPoolModeSystem AgentPoolMode = "System" + AgentPoolModeUser AgentPoolMode = "User" +) + +func PossibleValuesForAgentPoolMode() []string { + return []string{ + 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{ + "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 AgentPoolType string + +const ( + AgentPoolTypeAvailabilitySet AgentPoolType = "AvailabilitySet" + AgentPoolTypeVirtualMachineScaleSets AgentPoolType = "VirtualMachineScaleSets" +) + +func PossibleValuesForAgentPoolType() []string { + return []string{ + string(AgentPoolTypeAvailabilitySet), + string(AgentPoolTypeVirtualMachineScaleSets), + } +} + +func (s *AgentPoolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentPoolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentPoolType(input string) (*AgentPoolType, error) { + vals := map[string]AgentPoolType{ + "availabilityset": AgentPoolTypeAvailabilitySet, + "virtualmachinescalesets": AgentPoolTypeVirtualMachineScaleSets, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentPoolType(input) + return &out, nil +} + +type Code string + +const ( + CodeRunning Code = "Running" + CodeStopped Code = "Stopped" +) + +func PossibleValuesForCode() []string { + return []string{ + string(CodeRunning), + string(CodeStopped), + } +} + +func (s *Code) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCode(input string) (*Code, error) { + vals := map[string]Code{ + "running": CodeRunning, + "stopped": CodeStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Code(input) + return &out, nil +} + +type GPUDriver string + +const ( + GPUDriverInstall GPUDriver = "Install" + GPUDriverNone GPUDriver = "None" +) + +func PossibleValuesForGPUDriver() []string { + return []string{ + string(GPUDriverInstall), + string(GPUDriverNone), + } +} + +func (s *GPUDriver) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGPUDriver(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGPUDriver(input string) (*GPUDriver, error) { + vals := map[string]GPUDriver{ + "install": GPUDriverInstall, + "none": GPUDriverNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GPUDriver(input) + return &out, nil +} + +type GPUInstanceProfile string + +const ( + GPUInstanceProfileMIGFourg GPUInstanceProfile = "MIG4g" + GPUInstanceProfileMIGOneg GPUInstanceProfile = "MIG1g" + GPUInstanceProfileMIGSeveng GPUInstanceProfile = "MIG7g" + GPUInstanceProfileMIGThreeg GPUInstanceProfile = "MIG3g" + GPUInstanceProfileMIGTwog GPUInstanceProfile = "MIG2g" +) + +func PossibleValuesForGPUInstanceProfile() []string { + return []string{ + string(GPUInstanceProfileMIGFourg), + string(GPUInstanceProfileMIGOneg), + string(GPUInstanceProfileMIGSeveng), + string(GPUInstanceProfileMIGThreeg), + string(GPUInstanceProfileMIGTwog), + } +} + +func (s *GPUInstanceProfile) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGPUInstanceProfile(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGPUInstanceProfile(input string) (*GPUInstanceProfile, error) { + vals := map[string]GPUInstanceProfile{ + "mig4g": GPUInstanceProfileMIGFourg, + "mig1g": GPUInstanceProfileMIGOneg, + "mig7g": GPUInstanceProfileMIGSeveng, + "mig3g": GPUInstanceProfileMIGThreeg, + "mig2g": GPUInstanceProfileMIGTwog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GPUInstanceProfile(input) + return &out, nil +} + +type KubeletDiskType string + +const ( + KubeletDiskTypeOS KubeletDiskType = "OS" + KubeletDiskTypeTemporary KubeletDiskType = "Temporary" +) + +func PossibleValuesForKubeletDiskType() []string { + return []string{ + string(KubeletDiskTypeOS), + string(KubeletDiskTypeTemporary), + } +} + +func (s *KubeletDiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubeletDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubeletDiskType(input string) (*KubeletDiskType, error) { + vals := map[string]KubeletDiskType{ + "os": KubeletDiskTypeOS, + "temporary": KubeletDiskTypeTemporary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubeletDiskType(input) + return &out, nil +} + +type OSDiskType string + +const ( + OSDiskTypeEphemeral OSDiskType = "Ephemeral" + OSDiskTypeManaged OSDiskType = "Managed" +) + +func PossibleValuesForOSDiskType() []string { + return []string{ + string(OSDiskTypeEphemeral), + string(OSDiskTypeManaged), + } +} + +func (s *OSDiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSDiskType(input string) (*OSDiskType, error) { + vals := map[string]OSDiskType{ + "ephemeral": OSDiskTypeEphemeral, + "managed": OSDiskTypeManaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSDiskType(input) + return &out, nil +} + +type OSSKU string + +const ( + OSSKUAzureLinux OSSKU = "AzureLinux" + OSSKUCBLMariner OSSKU = "CBLMariner" + OSSKUUbuntu OSSKU = "Ubuntu" + OSSKUWindowsTwoZeroOneNine OSSKU = "Windows2019" + OSSKUWindowsTwoZeroTwoTwo OSSKU = "Windows2022" +) + +func PossibleValuesForOSSKU() []string { + return []string{ + string(OSSKUAzureLinux), + string(OSSKUCBLMariner), + string(OSSKUUbuntu), + string(OSSKUWindowsTwoZeroOneNine), + string(OSSKUWindowsTwoZeroTwoTwo), + } +} + +func (s *OSSKU) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSSKU(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSSKU(input string) (*OSSKU, error) { + vals := map[string]OSSKU{ + "azurelinux": OSSKUAzureLinux, + "cblmariner": OSSKUCBLMariner, + "ubuntu": OSSKUUbuntu, + "windows2019": OSSKUWindowsTwoZeroOneNine, + "windows2022": OSSKUWindowsTwoZeroTwoTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSSKU(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 Protocol string + +const ( + ProtocolTCP Protocol = "TCP" + ProtocolUDP Protocol = "UDP" +) + +func PossibleValuesForProtocol() []string { + return []string{ + string(ProtocolTCP), + string(ProtocolUDP), + } +} + +func (s *Protocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtocol(input string) (*Protocol, error) { + vals := map[string]Protocol{ + "tcp": ProtocolTCP, + "udp": ProtocolUDP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Protocol(input) + return &out, nil +} + +type ScaleDownMode string + +const ( + ScaleDownModeDeallocate ScaleDownMode = "Deallocate" + ScaleDownModeDelete ScaleDownMode = "Delete" +) + +func PossibleValuesForScaleDownMode() []string { + return []string{ + string(ScaleDownModeDeallocate), + string(ScaleDownModeDelete), + } +} + +func (s *ScaleDownMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleDownMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleDownMode(input string) (*ScaleDownMode, error) { + vals := map[string]ScaleDownMode{ + "deallocate": ScaleDownModeDeallocate, + "delete": ScaleDownModeDelete, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleDownMode(input) + return &out, nil +} + +type ScaleSetEvictionPolicy string + +const ( + ScaleSetEvictionPolicyDeallocate ScaleSetEvictionPolicy = "Deallocate" + ScaleSetEvictionPolicyDelete ScaleSetEvictionPolicy = "Delete" +) + +func PossibleValuesForScaleSetEvictionPolicy() []string { + return []string{ + string(ScaleSetEvictionPolicyDeallocate), + string(ScaleSetEvictionPolicyDelete), + } +} + +func (s *ScaleSetEvictionPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleSetEvictionPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleSetEvictionPolicy(input string) (*ScaleSetEvictionPolicy, error) { + vals := map[string]ScaleSetEvictionPolicy{ + "deallocate": ScaleSetEvictionPolicyDeallocate, + "delete": ScaleSetEvictionPolicyDelete, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleSetEvictionPolicy(input) + return &out, nil +} + +type ScaleSetPriority string + +const ( + ScaleSetPriorityRegular ScaleSetPriority = "Regular" + ScaleSetPrioritySpot ScaleSetPriority = "Spot" +) + +func PossibleValuesForScaleSetPriority() []string { + return []string{ + string(ScaleSetPriorityRegular), + string(ScaleSetPrioritySpot), + } +} + +func (s *ScaleSetPriority) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleSetPriority(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleSetPriority(input string) (*ScaleSetPriority, error) { + vals := map[string]ScaleSetPriority{ + "regular": ScaleSetPriorityRegular, + "spot": ScaleSetPrioritySpot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleSetPriority(input) + return &out, nil +} + +type WorkloadRuntime string + +const ( + WorkloadRuntimeOCIContainer WorkloadRuntime = "OCIContainer" + WorkloadRuntimeWasmWasi WorkloadRuntime = "WasmWasi" +) + +func PossibleValuesForWorkloadRuntime() []string { + return []string{ + string(WorkloadRuntimeOCIContainer), + string(WorkloadRuntimeWasmWasi), + } +} + +func (s *WorkloadRuntime) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkloadRuntime(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkloadRuntime(input string) (*WorkloadRuntime, error) { + vals := map[string]WorkloadRuntime{ + "ocicontainer": WorkloadRuntimeOCIContainer, + "wasmwasi": WorkloadRuntimeWasmWasi, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadRuntime(input) + return &out, nil +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/id_agentpool.go b/resource-manager/containerservice/2025-02-01/agentpools/id_agentpool.go new file mode 100644 index 00000000000..d1db170c217 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/id_agentpool.go @@ -0,0 +1,139 @@ +package agentpools + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) 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 + ManagedClusterName string + AgentPoolName string +} + +// NewAgentPoolID returns a new AgentPoolId struct +func NewAgentPoolID(subscriptionId string, resourceGroupName string, managedClusterName string, agentPoolName string) AgentPoolId { + return AgentPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", 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.ContainerService/managedClusters/%s/agentPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, 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("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterName"), + 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("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Agent Pool Name: %q", id.AgentPoolName), + } + return fmt.Sprintf("Agent Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/id_agentpool_test.go b/resource-manager/containerservice/2025-02-01/agentpools/id_agentpool_test.go new file mode 100644 index 00000000000..c11edfbefce --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/id_agentpool_test.go @@ -0,0 +1,327 @@ +package agentpools + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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", "managedClusterName", "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.ManagedClusterName != "managedClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterName") + } + + 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", "managedClusterName", "agentPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/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.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools/agentPoolName", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + AgentPoolName: "agentPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/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.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + 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.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/aGeNtPoOlS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools/agentPoolName", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + AgentPoolName: "agentPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/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.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/aGeNtPoOlS/aGeNtPoOlNaMe", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRnAmE", + 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.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/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.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + 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/containerservice/2025-02-01/agentpools/method_abortlatestoperation.go b/resource-manager/containerservice/2025-02-01/agentpools/method_abortlatestoperation.go new file mode 100644 index 00000000000..bb6d06d7487 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/method_abortlatestoperation.go @@ -0,0 +1,70 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AbortLatestOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AbortLatestOperation ... +func (c AgentPoolsClient) AbortLatestOperation(ctx context.Context, id AgentPoolId) (result AbortLatestOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/abort", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// AbortLatestOperationThenPoll performs AbortLatestOperation then polls until it's completed +func (c AgentPoolsClient) AbortLatestOperationThenPoll(ctx context.Context, id AgentPoolId) error { + result, err := c.AbortLatestOperation(ctx, id) + if err != nil { + return fmt.Errorf("performing AbortLatestOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AbortLatestOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/method_createorupdate.go b/resource-manager/containerservice/2025-02-01/agentpools/method_createorupdate.go new file mode 100644 index 00000000000..ac21aa2c854 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/method_createorupdate.go @@ -0,0 +1,108 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *AgentPool +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string + IfNoneMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + if o.IfNoneMatch != nil { + out.Append("If-None-Match", fmt.Sprintf("%v", *o.IfNoneMatch)) + } + 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 AgentPoolsClient) CreateOrUpdate(ctx context.Context, id AgentPoolId, input AgentPool, 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 AgentPoolsClient) CreateOrUpdateThenPoll(ctx context.Context, id AgentPoolId, input AgentPool, 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/containerservice/2025-02-01/agentpools/method_delete.go b/resource-manager/containerservice/2025-02-01/agentpools/method_delete.go new file mode 100644 index 00000000000..1e402c3c3f4 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/method_delete.go @@ -0,0 +1,102 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 { + IfMatch *string + IgnorePodDisruptionBudget *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IgnorePodDisruptionBudget != nil { + out.Append("ignore-pod-disruption-budget", fmt.Sprintf("%v", *o.IgnorePodDisruptionBudget)) + } + return &out +} + +// Delete ... +func (c AgentPoolsClient) Delete(ctx context.Context, id AgentPoolId, 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 AgentPoolsClient) DeleteThenPoll(ctx context.Context, id AgentPoolId, 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/containerservice/2025-02-01/agentpools/method_deletemachines.go b/resource-manager/containerservice/2025-02-01/agentpools/method_deletemachines.go new file mode 100644 index 00000000000..b07d10227fb --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/method_deletemachines.go @@ -0,0 +1,73 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteMachinesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteMachines ... +func (c AgentPoolsClient) DeleteMachines(ctx context.Context, id AgentPoolId, input AgentPoolDeleteMachinesParameter) (result DeleteMachinesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deleteMachines", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteMachinesThenPoll performs DeleteMachines then polls until it's completed +func (c AgentPoolsClient) DeleteMachinesThenPoll(ctx context.Context, id AgentPoolId, input AgentPoolDeleteMachinesParameter) error { + result, err := c.DeleteMachines(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DeleteMachines: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteMachines: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/method_get.go b/resource-manager/containerservice/2025-02-01/agentpools/method_get.go new file mode 100644 index 00000000000..ea20389e4a3 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/method_get.go @@ -0,0 +1,53 @@ +package agentpools + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *AgentPool +} + +// Get ... +func (c AgentPoolsClient) Get(ctx context.Context, id AgentPoolId) (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 AgentPool + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/method_getavailableagentpoolversions.go b/resource-manager/containerservice/2025-02-01/agentpools/method_getavailableagentpoolversions.go new file mode 100644 index 00000000000..685d4c2c2ec --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/method_getavailableagentpoolversions.go @@ -0,0 +1,55 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAvailableAgentPoolVersionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AgentPoolAvailableVersions +} + +// GetAvailableAgentPoolVersions ... +func (c AgentPoolsClient) GetAvailableAgentPoolVersions(ctx context.Context, id commonids.KubernetesClusterId) (result GetAvailableAgentPoolVersionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/availableAgentPoolVersions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AgentPoolAvailableVersions + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/method_getupgradeprofile.go b/resource-manager/containerservice/2025-02-01/agentpools/method_getupgradeprofile.go new file mode 100644 index 00000000000..1810ae898b6 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/method_getupgradeprofile.go @@ -0,0 +1,54 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetUpgradeProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AgentPoolUpgradeProfile +} + +// GetUpgradeProfile ... +func (c AgentPoolsClient) GetUpgradeProfile(ctx context.Context, id AgentPoolId) (result GetUpgradeProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/upgradeProfiles/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 AgentPoolUpgradeProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/method_list.go b/resource-manager/containerservice/2025-02-01/agentpools/method_list.go new file mode 100644 index 00000000000..63350a29f6d --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/method_list.go @@ -0,0 +1,106 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]AgentPool +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AgentPool +} + +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 AgentPoolsClient) List(ctx context.Context, id commonids.KubernetesClusterId) (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/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 +} + +// ListComplete retrieves all the results into a single object +func (c AgentPoolsClient) ListComplete(ctx context.Context, id commonids.KubernetesClusterId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AgentPoolOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AgentPoolsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.KubernetesClusterId, predicate AgentPoolOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AgentPool, 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/containerservice/2025-02-01/agentpools/method_upgradenodeimageversion.go b/resource-manager/containerservice/2025-02-01/agentpools/method_upgradenodeimageversion.go new file mode 100644 index 00000000000..fa6b0240a55 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/method_upgradenodeimageversion.go @@ -0,0 +1,71 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpgradeNodeImageVersionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AgentPool +} + +// UpgradeNodeImageVersion ... +func (c AgentPoolsClient) UpgradeNodeImageVersion(ctx context.Context, id AgentPoolId) (result UpgradeNodeImageVersionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/upgradeNodeImageVersion", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpgradeNodeImageVersionThenPoll performs UpgradeNodeImageVersion then polls until it's completed +func (c AgentPoolsClient) UpgradeNodeImageVersionThenPoll(ctx context.Context, id AgentPoolId) error { + result, err := c.UpgradeNodeImageVersion(ctx, id) + if err != nil { + return fmt.Errorf("performing UpgradeNodeImageVersion: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpgradeNodeImageVersion: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_agentpool.go b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpool.go new file mode 100644 index 00000000000..c67ae33e826 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpool.go @@ -0,0 +1,11 @@ +package agentpools + +// 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 { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagedClusterAgentPoolProfileProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolavailableversions.go b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolavailableversions.go new file mode 100644 index 00000000000..0b65a05c663 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolavailableversions.go @@ -0,0 +1,11 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolAvailableVersions struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties AgentPoolAvailableVersionsProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolavailableversionsproperties.go b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolavailableversionsproperties.go new file mode 100644 index 00000000000..a8369deaba7 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolavailableversionsproperties.go @@ -0,0 +1,8 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolAvailableVersionsProperties struct { + AgentPoolVersions *[]AgentPoolAvailableVersionsPropertiesAgentPoolVersionsInlined `json:"agentPoolVersions,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolavailableversionspropertiesagentpoolversionsinlined.go b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolavailableversionspropertiesagentpoolversionsinlined.go new file mode 100644 index 00000000000..1631b3137d1 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolavailableversionspropertiesagentpoolversionsinlined.go @@ -0,0 +1,10 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolAvailableVersionsPropertiesAgentPoolVersionsInlined struct { + Default *bool `json:"default,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_agentpooldeletemachinesparameter.go b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpooldeletemachinesparameter.go new file mode 100644 index 00000000000..f065e76b7a4 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpooldeletemachinesparameter.go @@ -0,0 +1,8 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolDeleteMachinesParameter struct { + MachineNames []string `json:"machineNames"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolnetworkprofile.go b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolnetworkprofile.go new file mode 100644 index 00000000000..db217a29cc5 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolnetworkprofile.go @@ -0,0 +1,10 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolNetworkProfile struct { + AllowedHostPorts *[]PortRange `json:"allowedHostPorts,omitempty"` + ApplicationSecurityGroups *[]string `json:"applicationSecurityGroups,omitempty"` + NodePublicIPTags *[]IPTag `json:"nodePublicIPTags,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolsecurityprofile.go b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolsecurityprofile.go new file mode 100644 index 00000000000..78ac43a520f --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolsecurityprofile.go @@ -0,0 +1,9 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolSecurityProfile struct { + EnableSecureBoot *bool `json:"enableSecureBoot,omitempty"` + EnableVTPM *bool `json:"enableVTPM,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolupgradeprofile.go b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolupgradeprofile.go new file mode 100644 index 00000000000..23cc2927f28 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolupgradeprofile.go @@ -0,0 +1,11 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolUpgradeProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties AgentPoolUpgradeProfileProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolupgradeprofileproperties.go b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolupgradeprofileproperties.go new file mode 100644 index 00000000000..5df00c96762 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolupgradeprofileproperties.go @@ -0,0 +1,11 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolUpgradeProfileProperties struct { + KubernetesVersion string `json:"kubernetesVersion"` + LatestNodeImageVersion *string `json:"latestNodeImageVersion,omitempty"` + OsType OSType `json:"osType"` + Upgrades *[]AgentPoolUpgradeProfilePropertiesUpgradesInlined `json:"upgrades,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolupgradeprofilepropertiesupgradesinlined.go b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolupgradeprofilepropertiesupgradesinlined.go new file mode 100644 index 00000000000..b45442f6cf0 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolupgradeprofilepropertiesupgradesinlined.go @@ -0,0 +1,9 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolUpgradeProfilePropertiesUpgradesInlined struct { + IsPreview *bool `json:"isPreview,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolupgradesettings.go b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolupgradesettings.go new file mode 100644 index 00000000000..c7afb34fc0c --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolupgradesettings.go @@ -0,0 +1,10 @@ +package agentpools + +// 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 { + DrainTimeoutInMinutes *int64 `json:"drainTimeoutInMinutes,omitempty"` + MaxSurge *string `json:"maxSurge,omitempty"` + NodeSoakDurationInMinutes *int64 `json:"nodeSoakDurationInMinutes,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolwindowsprofile.go b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolwindowsprofile.go new file mode 100644 index 00000000000..d7ad07f7f69 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_agentpoolwindowsprofile.go @@ -0,0 +1,8 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolWindowsProfile struct { + DisableOutboundNat *bool `json:"disableOutboundNat,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_creationdata.go b/resource-manager/containerservice/2025-02-01/agentpools/model_creationdata.go new file mode 100644 index 00000000000..88a8fe8123b --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_creationdata.go @@ -0,0 +1,8 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreationData struct { + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_gpuprofile.go b/resource-manager/containerservice/2025-02-01/agentpools/model_gpuprofile.go new file mode 100644 index 00000000000..89ac80213cf --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_gpuprofile.go @@ -0,0 +1,8 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GPUProfile struct { + Driver *GPUDriver `json:"driver,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_iptag.go b/resource-manager/containerservice/2025-02-01/agentpools/model_iptag.go new file mode 100644 index 00000000000..8a805afc241 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_iptag.go @@ -0,0 +1,9 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_kubeletconfig.go b/resource-manager/containerservice/2025-02-01/agentpools/model_kubeletconfig.go new file mode 100644 index 00000000000..7d56f79880c --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_kubeletconfig.go @@ -0,0 +1,18 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeletConfig struct { + AllowedUnsafeSysctls *[]string `json:"allowedUnsafeSysctls,omitempty"` + ContainerLogMaxFiles *int64 `json:"containerLogMaxFiles,omitempty"` + ContainerLogMaxSizeMB *int64 `json:"containerLogMaxSizeMB,omitempty"` + CpuCfsQuota *bool `json:"cpuCfsQuota,omitempty"` + CpuCfsQuotaPeriod *string `json:"cpuCfsQuotaPeriod,omitempty"` + CpuManagerPolicy *string `json:"cpuManagerPolicy,omitempty"` + FailSwapOn *bool `json:"failSwapOn,omitempty"` + ImageGcHighThreshold *int64 `json:"imageGcHighThreshold,omitempty"` + ImageGcLowThreshold *int64 `json:"imageGcLowThreshold,omitempty"` + PodMaxPids *int64 `json:"podMaxPids,omitempty"` + TopologyManagerPolicy *string `json:"topologyManagerPolicy,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_linuxosconfig.go b/resource-manager/containerservice/2025-02-01/agentpools/model_linuxosconfig.go new file mode 100644 index 00000000000..8256b210a85 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_linuxosconfig.go @@ -0,0 +1,11 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinuxOSConfig struct { + SwapFileSizeMB *int64 `json:"swapFileSizeMB,omitempty"` + Sysctls *SysctlConfig `json:"sysctls,omitempty"` + TransparentHugePageDefrag *string `json:"transparentHugePageDefrag,omitempty"` + TransparentHugePageEnabled *string `json:"transparentHugePageEnabled,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_managedclusteragentpoolprofileproperties.go b/resource-manager/containerservice/2025-02-01/agentpools/model_managedclusteragentpoolprofileproperties.go new file mode 100644 index 00000000000..7ed0301076d --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_managedclusteragentpoolprofileproperties.go @@ -0,0 +1,59 @@ +package agentpools + +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 ManagedClusterAgentPoolProfileProperties struct { + AvailabilityZones *zones.Schema `json:"availabilityZones,omitempty"` + CapacityReservationGroupID *string `json:"capacityReservationGroupID,omitempty"` + Count *int64 `json:"count,omitempty"` + CreationData *CreationData `json:"creationData,omitempty"` + CurrentOrchestratorVersion *string `json:"currentOrchestratorVersion,omitempty"` + ETag *string `json:"eTag,omitempty"` + EnableAutoScaling *bool `json:"enableAutoScaling,omitempty"` + EnableEncryptionAtHost *bool `json:"enableEncryptionAtHost,omitempty"` + EnableFIPS *bool `json:"enableFIPS,omitempty"` + EnableNodePublicIP *bool `json:"enableNodePublicIP,omitempty"` + EnableUltraSSD *bool `json:"enableUltraSSD,omitempty"` + GpuInstanceProfile *GPUInstanceProfile `json:"gpuInstanceProfile,omitempty"` + GpuProfile *GPUProfile `json:"gpuProfile,omitempty"` + HostGroupID *string `json:"hostGroupID,omitempty"` + KubeletConfig *KubeletConfig `json:"kubeletConfig,omitempty"` + KubeletDiskType *KubeletDiskType `json:"kubeletDiskType,omitempty"` + LinuxOSConfig *LinuxOSConfig `json:"linuxOSConfig,omitempty"` + MaxCount *int64 `json:"maxCount,omitempty"` + MaxPods *int64 `json:"maxPods,omitempty"` + MessageOfTheDay *string `json:"messageOfTheDay,omitempty"` + MinCount *int64 `json:"minCount,omitempty"` + Mode *AgentPoolMode `json:"mode,omitempty"` + NetworkProfile *AgentPoolNetworkProfile `json:"networkProfile,omitempty"` + NodeImageVersion *string `json:"nodeImageVersion,omitempty"` + NodeLabels *map[string]string `json:"nodeLabels,omitempty"` + NodePublicIPPrefixID *string `json:"nodePublicIPPrefixID,omitempty"` + NodeTaints *[]string `json:"nodeTaints,omitempty"` + OrchestratorVersion *string `json:"orchestratorVersion,omitempty"` + OsDiskSizeGB *int64 `json:"osDiskSizeGB,omitempty"` + OsDiskType *OSDiskType `json:"osDiskType,omitempty"` + OsSKU *OSSKU `json:"osSKU,omitempty"` + OsType *OSType `json:"osType,omitempty"` + PodSubnetID *string `json:"podSubnetID,omitempty"` + PowerState *PowerState `json:"powerState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ProximityPlacementGroupID *string `json:"proximityPlacementGroupID,omitempty"` + ScaleDownMode *ScaleDownMode `json:"scaleDownMode,omitempty"` + ScaleSetEvictionPolicy *ScaleSetEvictionPolicy `json:"scaleSetEvictionPolicy,omitempty"` + ScaleSetPriority *ScaleSetPriority `json:"scaleSetPriority,omitempty"` + SecurityProfile *AgentPoolSecurityProfile `json:"securityProfile,omitempty"` + SpotMaxPrice *float64 `json:"spotMaxPrice,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *AgentPoolType `json:"type,omitempty"` + UpgradeSettings *AgentPoolUpgradeSettings `json:"upgradeSettings,omitempty"` + VMSize *string `json:"vmSize,omitempty"` + VnetSubnetID *string `json:"vnetSubnetID,omitempty"` + WindowsProfile *AgentPoolWindowsProfile `json:"windowsProfile,omitempty"` + WorkloadRuntime *WorkloadRuntime `json:"workloadRuntime,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_portrange.go b/resource-manager/containerservice/2025-02-01/agentpools/model_portrange.go new file mode 100644 index 00000000000..45b2a562032 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_portrange.go @@ -0,0 +1,10 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PortRange struct { + PortEnd *int64 `json:"portEnd,omitempty"` + PortStart *int64 `json:"portStart,omitempty"` + Protocol *Protocol `json:"protocol,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_powerstate.go b/resource-manager/containerservice/2025-02-01/agentpools/model_powerstate.go new file mode 100644 index 00000000000..c5939d90672 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_powerstate.go @@ -0,0 +1,8 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PowerState struct { + Code *Code `json:"code,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/model_sysctlconfig.go b/resource-manager/containerservice/2025-02-01/agentpools/model_sysctlconfig.go new file mode 100644 index 00000000000..aa739bf4f68 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/model_sysctlconfig.go @@ -0,0 +1,35 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SysctlConfig struct { + FsAioMaxNr *int64 `json:"fsAioMaxNr,omitempty"` + FsFileMax *int64 `json:"fsFileMax,omitempty"` + FsInotifyMaxUserWatches *int64 `json:"fsInotifyMaxUserWatches,omitempty"` + FsNrOpen *int64 `json:"fsNrOpen,omitempty"` + KernelThreadsMax *int64 `json:"kernelThreadsMax,omitempty"` + NetCoreNetdevMaxBacklog *int64 `json:"netCoreNetdevMaxBacklog,omitempty"` + NetCoreOptmemMax *int64 `json:"netCoreOptmemMax,omitempty"` + NetCoreRmemDefault *int64 `json:"netCoreRmemDefault,omitempty"` + NetCoreRmemMax *int64 `json:"netCoreRmemMax,omitempty"` + NetCoreSomaxconn *int64 `json:"netCoreSomaxconn,omitempty"` + NetCoreWmemDefault *int64 `json:"netCoreWmemDefault,omitempty"` + NetCoreWmemMax *int64 `json:"netCoreWmemMax,omitempty"` + NetIPv4IPLocalPortRange *string `json:"netIpv4IpLocalPortRange,omitempty"` + NetIPv4NeighDefaultGcThresh1 *int64 `json:"netIpv4NeighDefaultGcThresh1,omitempty"` + NetIPv4NeighDefaultGcThresh2 *int64 `json:"netIpv4NeighDefaultGcThresh2,omitempty"` + NetIPv4NeighDefaultGcThresh3 *int64 `json:"netIpv4NeighDefaultGcThresh3,omitempty"` + NetIPv4TcpFinTimeout *int64 `json:"netIpv4TcpFinTimeout,omitempty"` + NetIPv4TcpKeepaliveProbes *int64 `json:"netIpv4TcpKeepaliveProbes,omitempty"` + NetIPv4TcpKeepaliveTime *int64 `json:"netIpv4TcpKeepaliveTime,omitempty"` + NetIPv4TcpMaxSynBacklog *int64 `json:"netIpv4TcpMaxSynBacklog,omitempty"` + NetIPv4TcpMaxTwBuckets *int64 `json:"netIpv4TcpMaxTwBuckets,omitempty"` + NetIPv4TcpTwReuse *bool `json:"netIpv4TcpTwReuse,omitempty"` + NetIPv4TcpkeepaliveIntvl *int64 `json:"netIpv4TcpkeepaliveIntvl,omitempty"` + NetNetfilterNfConntrackBuckets *int64 `json:"netNetfilterNfConntrackBuckets,omitempty"` + NetNetfilterNfConntrackMax *int64 `json:"netNetfilterNfConntrackMax,omitempty"` + VMMaxMapCount *int64 `json:"vmMaxMapCount,omitempty"` + VMSwappiness *int64 `json:"vmSwappiness,omitempty"` + VMVfsCachePressure *int64 `json:"vmVfsCachePressure,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/agentpools/predicates.go b/resource-manager/containerservice/2025-02-01/agentpools/predicates.go new file mode 100644 index 00000000000..94a2db5c63b --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/predicates.go @@ -0,0 +1,27 @@ +package agentpools + +// 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 + 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.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/containerservice/2025-02-01/agentpools/version.go b/resource-manager/containerservice/2025-02-01/agentpools/version.go new file mode 100644 index 00000000000..f16d57277d2 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/agentpools/version.go @@ -0,0 +1,10 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/agentpools/2025-02-01" +} diff --git a/resource-manager/containerservice/2025-02-01/client.go b/resource-manager/containerservice/2025-02-01/client.go new file mode 100644 index 00000000000..7cf7b6f9f90 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/client.go @@ -0,0 +1,100 @@ +package v2025_02_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/containerservice/2025-02-01/agentpools" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/machines" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/maintenanceconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/managedclusters" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/privateendpointconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/privatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/snapshots" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/trustedaccess" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AgentPools *agentpools.AgentPoolsClient + Machines *machines.MachinesClient + MaintenanceConfigurations *maintenanceconfigurations.MaintenanceConfigurationsClient + ManagedClusters *managedclusters.ManagedClustersClient + PrivateEndpointConnections *privateendpointconnections.PrivateEndpointConnectionsClient + PrivateLinkResources *privatelinkresources.PrivateLinkResourcesClient + ResolvePrivateLinkServiceId *resolveprivatelinkserviceid.ResolvePrivateLinkServiceIdClient + Snapshots *snapshots.SnapshotsClient + TrustedAccess *trustedaccess.TrustedAccessClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + agentPoolsClient, err := agentpools.NewAgentPoolsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AgentPools client: %+v", err) + } + configureFunc(agentPoolsClient.Client) + + machinesClient, err := machines.NewMachinesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Machines client: %+v", err) + } + configureFunc(machinesClient.Client) + + maintenanceConfigurationsClient, err := maintenanceconfigurations.NewMaintenanceConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MaintenanceConfigurations client: %+v", err) + } + configureFunc(maintenanceConfigurationsClient.Client) + + managedClustersClient, err := managedclusters.NewManagedClustersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedClusters client: %+v", err) + } + configureFunc(managedClustersClient.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) + + resolvePrivateLinkServiceIdClient, err := resolveprivatelinkserviceid.NewResolvePrivateLinkServiceIdClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ResolvePrivateLinkServiceId client: %+v", err) + } + configureFunc(resolvePrivateLinkServiceIdClient.Client) + + snapshotsClient, err := snapshots.NewSnapshotsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Snapshots client: %+v", err) + } + configureFunc(snapshotsClient.Client) + + trustedAccessClient, err := trustedaccess.NewTrustedAccessClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building TrustedAccess client: %+v", err) + } + configureFunc(trustedAccessClient.Client) + + return &Client{ + AgentPools: agentPoolsClient, + Machines: machinesClient, + MaintenanceConfigurations: maintenanceConfigurationsClient, + ManagedClusters: managedClustersClient, + PrivateEndpointConnections: privateEndpointConnectionsClient, + PrivateLinkResources: privateLinkResourcesClient, + ResolvePrivateLinkServiceId: resolvePrivateLinkServiceIdClient, + Snapshots: snapshotsClient, + TrustedAccess: trustedAccessClient, + }, nil +} diff --git a/resource-manager/containerservice/2025-02-01/machines/README.md b/resource-manager/containerservice/2025-02-01/machines/README.md new file mode 100644 index 00000000000..6a20787970e --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/machines` Documentation + +The `machines` SDK allows for interaction with Azure Resource Manager `containerservice` (API Version `2025-02-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/containerservice/2025-02-01/machines" +``` + + +### Client Initialization + +```go +client := machines.NewMachinesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MachinesClient.Get` + +```go +ctx := context.TODO() +id := machines.NewMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "agentPoolName", "machineName") + +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: `MachinesClient.List` + +```go +ctx := context.TODO() +id := machines.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "agentPoolName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/containerservice/2025-02-01/machines/client.go b/resource-manager/containerservice/2025-02-01/machines/client.go new file mode 100644 index 00000000000..fcd8a61002f --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/client.go @@ -0,0 +1,26 @@ +package machines + +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 MachinesClient struct { + Client *resourcemanager.Client +} + +func NewMachinesClientWithBaseURI(sdkApi sdkEnv.Api) (*MachinesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "machines", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MachinesClient: %+v", err) + } + + return &MachinesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2025-02-01/machines/constants.go b/resource-manager/containerservice/2025-02-01/machines/constants.go new file mode 100644 index 00000000000..3401f05d4e3 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/constants.go @@ -0,0 +1,51 @@ +package machines + +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 IPFamily string + +const ( + IPFamilyIPvFour IPFamily = "IPv4" + IPFamilyIPvSix IPFamily = "IPv6" +) + +func PossibleValuesForIPFamily() []string { + return []string{ + string(IPFamilyIPvFour), + string(IPFamilyIPvSix), + } +} + +func (s *IPFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPFamily(input string) (*IPFamily, error) { + vals := map[string]IPFamily{ + "ipv4": IPFamilyIPvFour, + "ipv6": IPFamilyIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPFamily(input) + return &out, nil +} diff --git a/resource-manager/containerservice/2025-02-01/machines/id_agentpool.go b/resource-manager/containerservice/2025-02-01/machines/id_agentpool.go new file mode 100644 index 00000000000..591db14c283 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/id_agentpool.go @@ -0,0 +1,139 @@ +package machines + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) 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 + ManagedClusterName string + AgentPoolName string +} + +// NewAgentPoolID returns a new AgentPoolId struct +func NewAgentPoolID(subscriptionId string, resourceGroupName string, managedClusterName string, agentPoolName string) AgentPoolId { + return AgentPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", 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.ContainerService/managedClusters/%s/agentPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, 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("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterName"), + 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("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Agent Pool Name: %q", id.AgentPoolName), + } + return fmt.Sprintf("Agent Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2025-02-01/machines/id_agentpool_test.go b/resource-manager/containerservice/2025-02-01/machines/id_agentpool_test.go new file mode 100644 index 00000000000..a8bfe45062b --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/id_agentpool_test.go @@ -0,0 +1,327 @@ +package machines + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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", "managedClusterName", "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.ManagedClusterName != "managedClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterName") + } + + 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", "managedClusterName", "agentPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/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.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools/agentPoolName", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + AgentPoolName: "agentPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/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.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + 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.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/aGeNtPoOlS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools/agentPoolName", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + AgentPoolName: "agentPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/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.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/aGeNtPoOlS/aGeNtPoOlNaMe", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRnAmE", + 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.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/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.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + 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/containerservice/2025-02-01/machines/id_machine.go b/resource-manager/containerservice/2025-02-01/machines/id_machine.go new file mode 100644 index 00000000000..3cf8b2ccbf0 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/id_machine.go @@ -0,0 +1,148 @@ +package machines + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MachineId{}) +} + +var _ resourceids.ResourceId = &MachineId{} + +// MachineId is a struct representing the Resource ID for a Machine +type MachineId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + AgentPoolName string + MachineName string +} + +// NewMachineID returns a new MachineId struct +func NewMachineID(subscriptionId string, resourceGroupName string, managedClusterName string, agentPoolName string, machineName string) MachineId { + return MachineId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + AgentPoolName: agentPoolName, + MachineName: machineName, + } +} + +// ParseMachineID parses 'input' into a MachineId +func ParseMachineID(input string) (*MachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&MachineId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MachineId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMachineIDInsensitively parses 'input' case-insensitively into a MachineId +// note: this method should only be used for API response data and not user input +func ParseMachineIDInsensitively(input string) (*MachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&MachineId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MachineId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MachineId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.AgentPoolName, ok = input.Parsed["agentPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "agentPoolName", input) + } + + if id.MachineName, ok = input.Parsed["machineName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "machineName", input) + } + + return nil +} + +// ValidateMachineID checks that 'input' can be parsed as a Machine ID +func ValidateMachineID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseMachineID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Machine ID +func (id MachineId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/agentPools/%s/machines/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.AgentPoolName, id.MachineName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Machine ID +func (id MachineId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterName"), + resourceids.StaticSegment("staticAgentPools", "agentPools", "agentPools"), + resourceids.UserSpecifiedSegment("agentPoolName", "agentPoolName"), + resourceids.StaticSegment("staticMachines", "machines", "machines"), + resourceids.UserSpecifiedSegment("machineName", "machineName"), + } +} + +// String returns a human-readable description of this Machine ID +func (id MachineId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Agent Pool Name: %q", id.AgentPoolName), + fmt.Sprintf("Machine Name: %q", id.MachineName), + } + return fmt.Sprintf("Machine (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2025-02-01/machines/id_machine_test.go b/resource-manager/containerservice/2025-02-01/machines/id_machine_test.go new file mode 100644 index 00000000000..a94383704e7 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/id_machine_test.go @@ -0,0 +1,372 @@ +package machines + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MachineId{} + +func TestNewMachineID(t *testing.T) { + id := NewMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "agentPoolName", "machineName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterName") + } + + if id.AgentPoolName != "agentPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'AgentPoolName'", id.AgentPoolName, "agentPoolName") + } + + if id.MachineName != "machineName" { + t.Fatalf("Expected %q but got %q for Segment 'MachineName'", id.MachineName, "machineName") + } +} + +func TestFormatMachineID(t *testing.T) { + actual := NewMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "agentPoolName", "machineName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools/agentPoolName/machines/machineName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMachineID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MachineId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools/agentPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools/agentPoolName/machines", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools/agentPoolName/machines/machineName", + Expected: &MachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + AgentPoolName: "agentPoolName", + MachineName: "machineName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools/agentPoolName/machines/machineName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMachineID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.AgentPoolName != v.Expected.AgentPoolName { + t.Fatalf("Expected %q but got %q for AgentPoolName", v.Expected.AgentPoolName, actual.AgentPoolName) + } + + if actual.MachineName != v.Expected.MachineName { + t.Fatalf("Expected %q but got %q for MachineName", v.Expected.MachineName, actual.MachineName) + } + + } +} + +func TestParseMachineIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MachineId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/aGeNtPoOlS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools/agentPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/aGeNtPoOlS/aGeNtPoOlNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools/agentPoolName/machines", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/aGeNtPoOlS/aGeNtPoOlNaMe/mAcHiNeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools/agentPoolName/machines/machineName", + Expected: &MachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + AgentPoolName: "agentPoolName", + MachineName: "machineName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/agentPools/agentPoolName/machines/machineName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/aGeNtPoOlS/aGeNtPoOlNaMe/mAcHiNeS/mAcHiNeNaMe", + Expected: &MachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRnAmE", + AgentPoolName: "aGeNtPoOlNaMe", + MachineName: "mAcHiNeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/aGeNtPoOlS/aGeNtPoOlNaMe/mAcHiNeS/mAcHiNeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMachineIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.AgentPoolName != v.Expected.AgentPoolName { + t.Fatalf("Expected %q but got %q for AgentPoolName", v.Expected.AgentPoolName, actual.AgentPoolName) + } + + if actual.MachineName != v.Expected.MachineName { + t.Fatalf("Expected %q but got %q for MachineName", v.Expected.MachineName, actual.MachineName) + } + + } +} + +func TestSegmentsForMachineId(t *testing.T) { + segments := MachineId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MachineId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2025-02-01/machines/method_get.go b/resource-manager/containerservice/2025-02-01/machines/method_get.go new file mode 100644 index 00000000000..14636e392c1 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/method_get.go @@ -0,0 +1,53 @@ +package machines + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Machine +} + +// Get ... +func (c MachinesClient) Get(ctx context.Context, id MachineId) (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 Machine + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/machines/method_list.go b/resource-manager/containerservice/2025-02-01/machines/method_list.go new file mode 100644 index 00000000000..949d16fc5e3 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/method_list.go @@ -0,0 +1,105 @@ +package machines + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]Machine +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Machine +} + +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 MachinesClient) List(ctx context.Context, id AgentPoolId) (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/machines", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Machine `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 MachinesClient) ListComplete(ctx context.Context, id AgentPoolId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, MachineOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MachinesClient) ListCompleteMatchingPredicate(ctx context.Context, id AgentPoolId, predicate MachineOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Machine, 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/containerservice/2025-02-01/machines/model_machine.go b/resource-manager/containerservice/2025-02-01/machines/model_machine.go new file mode 100644 index 00000000000..33038791b72 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/model_machine.go @@ -0,0 +1,11 @@ +package machines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Machine struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MachineProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/machines/model_machineipaddress.go b/resource-manager/containerservice/2025-02-01/machines/model_machineipaddress.go new file mode 100644 index 00000000000..213cc86efcc --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/model_machineipaddress.go @@ -0,0 +1,9 @@ +package machines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MachineIPAddress struct { + Family *IPFamily `json:"family,omitempty"` + IP *string `json:"ip,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/machines/model_machinenetworkproperties.go b/resource-manager/containerservice/2025-02-01/machines/model_machinenetworkproperties.go new file mode 100644 index 00000000000..5183ee2722f --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/model_machinenetworkproperties.go @@ -0,0 +1,8 @@ +package machines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MachineNetworkProperties struct { + IPAddresses *[]MachineIPAddress `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/machines/model_machineproperties.go b/resource-manager/containerservice/2025-02-01/machines/model_machineproperties.go new file mode 100644 index 00000000000..041457c0e7c --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/model_machineproperties.go @@ -0,0 +1,9 @@ +package machines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MachineProperties struct { + Network *MachineNetworkProperties `json:"network,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/machines/predicates.go b/resource-manager/containerservice/2025-02-01/machines/predicates.go new file mode 100644 index 00000000000..ebc0babfdc2 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/predicates.go @@ -0,0 +1,27 @@ +package machines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MachineOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p MachineOperationPredicate) Matches(input Machine) 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/containerservice/2025-02-01/machines/version.go b/resource-manager/containerservice/2025-02-01/machines/version.go new file mode 100644 index 00000000000..4fe27f2c2e2 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/machines/version.go @@ -0,0 +1,10 @@ +package machines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/machines/2025-02-01" +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/README.md b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/README.md new file mode 100644 index 00000000000..d0168fb40af --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/README.md @@ -0,0 +1,91 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/maintenanceconfigurations` Documentation + +The `maintenanceconfigurations` SDK allows for interaction with Azure Resource Manager `containerservice` (API Version `2025-02-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/containerservice/2025-02-01/maintenanceconfigurations" +``` + + +### Client Initialization + +```go +client := maintenanceconfigurations.NewMaintenanceConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MaintenanceConfigurationsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := maintenanceconfigurations.NewMaintenanceConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "maintenanceConfigurationName") + +payload := maintenanceconfigurations.MaintenanceConfiguration{ + // ... +} + + +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: `MaintenanceConfigurationsClient.Delete` + +```go +ctx := context.TODO() +id := maintenanceconfigurations.NewMaintenanceConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "maintenanceConfigurationName") + +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: `MaintenanceConfigurationsClient.Get` + +```go +ctx := context.TODO() +id := maintenanceconfigurations.NewMaintenanceConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "maintenanceConfigurationName") + +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: `MaintenanceConfigurationsClient.ListByManagedCluster` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +// alternatively `client.ListByManagedCluster(ctx, id)` can be used to do batched pagination +items, err := client.ListByManagedClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/client.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/client.go new file mode 100644 index 00000000000..bcb48de3779 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/client.go @@ -0,0 +1,26 @@ +package maintenanceconfigurations + +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 MaintenanceConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewMaintenanceConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*MaintenanceConfigurationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "maintenanceconfigurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MaintenanceConfigurationsClient: %+v", err) + } + + return &MaintenanceConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/constants.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/constants.go new file mode 100644 index 00000000000..2fdd49e9763 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/constants.go @@ -0,0 +1,116 @@ +package maintenanceconfigurations + +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 ( + TypeFirst Type = "First" + TypeFourth Type = "Fourth" + TypeLast Type = "Last" + TypeSecond Type = "Second" + TypeThird Type = "Third" +) + +func PossibleValuesForType() []string { + return []string{ + string(TypeFirst), + string(TypeFourth), + string(TypeLast), + string(TypeSecond), + string(TypeThird), + } +} + +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{ + "first": TypeFirst, + "fourth": TypeFourth, + "last": TypeLast, + "second": TypeSecond, + "third": TypeThird, + } + 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 +} + +type WeekDay string + +const ( + WeekDayFriday WeekDay = "Friday" + WeekDayMonday WeekDay = "Monday" + WeekDaySaturday WeekDay = "Saturday" + WeekDaySunday WeekDay = "Sunday" + WeekDayThursday WeekDay = "Thursday" + WeekDayTuesday WeekDay = "Tuesday" + WeekDayWednesday WeekDay = "Wednesday" +) + +func PossibleValuesForWeekDay() []string { + return []string{ + string(WeekDayFriday), + string(WeekDayMonday), + string(WeekDaySaturday), + string(WeekDaySunday), + string(WeekDayThursday), + string(WeekDayTuesday), + string(WeekDayWednesday), + } +} + +func (s *WeekDay) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWeekDay(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWeekDay(input string) (*WeekDay, error) { + vals := map[string]WeekDay{ + "friday": WeekDayFriday, + "monday": WeekDayMonday, + "saturday": WeekDaySaturday, + "sunday": WeekDaySunday, + "thursday": WeekDayThursday, + "tuesday": WeekDayTuesday, + "wednesday": WeekDayWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WeekDay(input) + return &out, nil +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/id_maintenanceconfiguration.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/id_maintenanceconfiguration.go new file mode 100644 index 00000000000..a06e5519459 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/id_maintenanceconfiguration.go @@ -0,0 +1,139 @@ +package maintenanceconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MaintenanceConfigurationId{}) +} + +var _ resourceids.ResourceId = &MaintenanceConfigurationId{} + +// MaintenanceConfigurationId is a struct representing the Resource ID for a Maintenance Configuration +type MaintenanceConfigurationId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + MaintenanceConfigurationName string +} + +// NewMaintenanceConfigurationID returns a new MaintenanceConfigurationId struct +func NewMaintenanceConfigurationID(subscriptionId string, resourceGroupName string, managedClusterName string, maintenanceConfigurationName string) MaintenanceConfigurationId { + return MaintenanceConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + MaintenanceConfigurationName: maintenanceConfigurationName, + } +} + +// ParseMaintenanceConfigurationID parses 'input' into a MaintenanceConfigurationId +func ParseMaintenanceConfigurationID(input string) (*MaintenanceConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&MaintenanceConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MaintenanceConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMaintenanceConfigurationIDInsensitively parses 'input' case-insensitively into a MaintenanceConfigurationId +// note: this method should only be used for API response data and not user input +func ParseMaintenanceConfigurationIDInsensitively(input string) (*MaintenanceConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&MaintenanceConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MaintenanceConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MaintenanceConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.MaintenanceConfigurationName, ok = input.Parsed["maintenanceConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "maintenanceConfigurationName", input) + } + + return nil +} + +// ValidateMaintenanceConfigurationID checks that 'input' can be parsed as a Maintenance Configuration ID +func ValidateMaintenanceConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseMaintenanceConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Maintenance Configuration ID +func (id MaintenanceConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/maintenanceConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.MaintenanceConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Maintenance Configuration ID +func (id MaintenanceConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterName"), + resourceids.StaticSegment("staticMaintenanceConfigurations", "maintenanceConfigurations", "maintenanceConfigurations"), + resourceids.UserSpecifiedSegment("maintenanceConfigurationName", "maintenanceConfigurationName"), + } +} + +// String returns a human-readable description of this Maintenance Configuration ID +func (id MaintenanceConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Maintenance Configuration Name: %q", id.MaintenanceConfigurationName), + } + return fmt.Sprintf("Maintenance Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/id_maintenanceconfiguration_test.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/id_maintenanceconfiguration_test.go new file mode 100644 index 00000000000..d5d0ad17780 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/id_maintenanceconfiguration_test.go @@ -0,0 +1,327 @@ +package maintenanceconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MaintenanceConfigurationId{} + +func TestNewMaintenanceConfigurationID(t *testing.T) { + id := NewMaintenanceConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "maintenanceConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterName") + } + + if id.MaintenanceConfigurationName != "maintenanceConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'MaintenanceConfigurationName'", id.MaintenanceConfigurationName, "maintenanceConfigurationName") + } +} + +func TestFormatMaintenanceConfigurationID(t *testing.T) { + actual := NewMaintenanceConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "maintenanceConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/maintenanceConfigurations/maintenanceConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMaintenanceConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MaintenanceConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/maintenanceConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/maintenanceConfigurations/maintenanceConfigurationName", + Expected: &MaintenanceConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + MaintenanceConfigurationName: "maintenanceConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/maintenanceConfigurations/maintenanceConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMaintenanceConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.MaintenanceConfigurationName != v.Expected.MaintenanceConfigurationName { + t.Fatalf("Expected %q but got %q for MaintenanceConfigurationName", v.Expected.MaintenanceConfigurationName, actual.MaintenanceConfigurationName) + } + + } +} + +func TestParseMaintenanceConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MaintenanceConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/maintenanceConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/mAiNtEnAnCeCoNfIgUrAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/maintenanceConfigurations/maintenanceConfigurationName", + Expected: &MaintenanceConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + MaintenanceConfigurationName: "maintenanceConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/maintenanceConfigurations/maintenanceConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/mAiNtEnAnCeCoNfIgUrAtIoNs/mAiNtEnAnCeCoNfIgUrAtIoNnAmE", + Expected: &MaintenanceConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRnAmE", + MaintenanceConfigurationName: "mAiNtEnAnCeCoNfIgUrAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/mAiNtEnAnCeCoNfIgUrAtIoNs/mAiNtEnAnCeCoNfIgUrAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMaintenanceConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.MaintenanceConfigurationName != v.Expected.MaintenanceConfigurationName { + t.Fatalf("Expected %q but got %q for MaintenanceConfigurationName", v.Expected.MaintenanceConfigurationName, actual.MaintenanceConfigurationName) + } + + } +} + +func TestSegmentsForMaintenanceConfigurationId(t *testing.T) { + segments := MaintenanceConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MaintenanceConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/method_createorupdate.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/method_createorupdate.go new file mode 100644 index 00000000000..a6e8fc75722 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/method_createorupdate.go @@ -0,0 +1,58 @@ +package maintenanceconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *MaintenanceConfiguration +} + +// CreateOrUpdate ... +func (c MaintenanceConfigurationsClient) CreateOrUpdate(ctx context.Context, id MaintenanceConfigurationId, input MaintenanceConfiguration) (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 MaintenanceConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/method_delete.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/method_delete.go new file mode 100644 index 00000000000..5993be4c15a --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/method_delete.go @@ -0,0 +1,47 @@ +package maintenanceconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 MaintenanceConfigurationsClient) Delete(ctx context.Context, id MaintenanceConfigurationId) (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/containerservice/2025-02-01/maintenanceconfigurations/method_get.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/method_get.go new file mode 100644 index 00000000000..3989652ca96 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/method_get.go @@ -0,0 +1,53 @@ +package maintenanceconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *MaintenanceConfiguration +} + +// Get ... +func (c MaintenanceConfigurationsClient) Get(ctx context.Context, id MaintenanceConfigurationId) (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 MaintenanceConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/method_listbymanagedcluster.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/method_listbymanagedcluster.go new file mode 100644 index 00000000000..f87e9032ed5 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/method_listbymanagedcluster.go @@ -0,0 +1,106 @@ +package maintenanceconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByManagedClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MaintenanceConfiguration +} + +type ListByManagedClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []MaintenanceConfiguration +} + +type ListByManagedClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByManagedClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByManagedCluster ... +func (c MaintenanceConfigurationsClient) ListByManagedCluster(ctx context.Context, id commonids.KubernetesClusterId) (result ListByManagedClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByManagedClusterCustomPager{}, + Path: fmt.Sprintf("%s/maintenanceConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MaintenanceConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByManagedClusterComplete retrieves all the results into a single object +func (c MaintenanceConfigurationsClient) ListByManagedClusterComplete(ctx context.Context, id commonids.KubernetesClusterId) (ListByManagedClusterCompleteResult, error) { + return c.ListByManagedClusterCompleteMatchingPredicate(ctx, id, MaintenanceConfigurationOperationPredicate{}) +} + +// ListByManagedClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MaintenanceConfigurationsClient) ListByManagedClusterCompleteMatchingPredicate(ctx context.Context, id commonids.KubernetesClusterId, predicate MaintenanceConfigurationOperationPredicate) (result ListByManagedClusterCompleteResult, err error) { + items := make([]MaintenanceConfiguration, 0) + + resp, err := c.ListByManagedCluster(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 = ListByManagedClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_absolutemonthlyschedule.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_absolutemonthlyschedule.go new file mode 100644 index 00000000000..ca6966896ff --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_absolutemonthlyschedule.go @@ -0,0 +1,9 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AbsoluteMonthlySchedule struct { + DayOfMonth int64 `json:"dayOfMonth"` + IntervalMonths int64 `json:"intervalMonths"` +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_dailyschedule.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_dailyschedule.go new file mode 100644 index 00000000000..57fb3e994dd --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_dailyschedule.go @@ -0,0 +1,8 @@ +package maintenanceconfigurations + +// 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 { + IntervalDays int64 `json:"intervalDays"` +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_datespan.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_datespan.go new file mode 100644 index 00000000000..863c4704427 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_datespan.go @@ -0,0 +1,9 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DateSpan struct { + End string `json:"end"` + Start string `json:"start"` +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_maintenanceconfiguration.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_maintenanceconfiguration.go new file mode 100644 index 00000000000..9066e53bff3 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_maintenanceconfiguration.go @@ -0,0 +1,16 @@ +package maintenanceconfigurations + +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 MaintenanceConfiguration struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MaintenanceConfigurationProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_maintenanceconfigurationproperties.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_maintenanceconfigurationproperties.go new file mode 100644 index 00000000000..d7c91bcf9f6 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_maintenanceconfigurationproperties.go @@ -0,0 +1,10 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MaintenanceConfigurationProperties struct { + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + NotAllowedTime *[]TimeSpan `json:"notAllowedTime,omitempty"` + TimeInWeek *[]TimeInWeek `json:"timeInWeek,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_maintenancewindow.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_maintenancewindow.go new file mode 100644 index 00000000000..8f1a42f818c --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_maintenancewindow.go @@ -0,0 +1,13 @@ +package maintenanceconfigurations + +// 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 { + DurationHours int64 `json:"durationHours"` + NotAllowedDates *[]DateSpan `json:"notAllowedDates,omitempty"` + Schedule Schedule `json:"schedule"` + StartDate *string `json:"startDate,omitempty"` + StartTime string `json:"startTime"` + UtcOffset *string `json:"utcOffset,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_relativemonthlyschedule.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_relativemonthlyschedule.go new file mode 100644 index 00000000000..0dfc104da98 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_relativemonthlyschedule.go @@ -0,0 +1,10 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RelativeMonthlySchedule struct { + DayOfWeek WeekDay `json:"dayOfWeek"` + IntervalMonths int64 `json:"intervalMonths"` + WeekIndex Type `json:"weekIndex"` +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_schedule.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_schedule.go new file mode 100644 index 00000000000..cc4397aba4c --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_schedule.go @@ -0,0 +1,11 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Schedule struct { + AbsoluteMonthly *AbsoluteMonthlySchedule `json:"absoluteMonthly,omitempty"` + Daily *DailySchedule `json:"daily,omitempty"` + RelativeMonthly *RelativeMonthlySchedule `json:"relativeMonthly,omitempty"` + Weekly *WeeklySchedule `json:"weekly,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_timeinweek.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_timeinweek.go new file mode 100644 index 00000000000..cba259f76fc --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_timeinweek.go @@ -0,0 +1,9 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TimeInWeek struct { + Day *WeekDay `json:"day,omitempty"` + HourSlots *[]int64 `json:"hourSlots,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_timespan.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_timespan.go new file mode 100644 index 00000000000..7bbc8c5ba72 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_timespan.go @@ -0,0 +1,39 @@ +package maintenanceconfigurations + +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 TimeSpan struct { + End *string `json:"end,omitempty"` + Start *string `json:"start,omitempty"` +} + +func (o *TimeSpan) GetEndAsTime() (*time.Time, error) { + if o.End == nil { + return nil, nil + } + return dates.ParseAsFormat(o.End, "2006-01-02T15:04:05Z07:00") +} + +func (o *TimeSpan) SetEndAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.End = &formatted +} + +func (o *TimeSpan) GetStartAsTime() (*time.Time, error) { + if o.Start == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Start, "2006-01-02T15:04:05Z07:00") +} + +func (o *TimeSpan) SetStartAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Start = &formatted +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_weeklyschedule.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_weeklyschedule.go new file mode 100644 index 00000000000..ed775ad784e --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/model_weeklyschedule.go @@ -0,0 +1,9 @@ +package maintenanceconfigurations + +// 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 { + DayOfWeek WeekDay `json:"dayOfWeek"` + IntervalWeeks int64 `json:"intervalWeeks"` +} diff --git a/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/predicates.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/predicates.go new file mode 100644 index 00000000000..c7eedb4fa7b --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/predicates.go @@ -0,0 +1,27 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MaintenanceConfigurationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p MaintenanceConfigurationOperationPredicate) Matches(input MaintenanceConfiguration) 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/containerservice/2025-02-01/maintenanceconfigurations/version.go b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/version.go new file mode 100644 index 00000000000..7c72ae57526 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/maintenanceconfigurations/version.go @@ -0,0 +1,10 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/maintenanceconfigurations/2025-02-01" +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/README.md b/resource-manager/containerservice/2025-02-01/managedclusters/README.md new file mode 100644 index 00000000000..97ee8c165ed --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/README.md @@ -0,0 +1,423 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/managedclusters` Documentation + +The `managedclusters` SDK allows for interaction with Azure Resource Manager `containerservice` (API Version `2025-02-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/containerservice/2025-02-01/managedclusters" +``` + + +### Client Initialization + +```go +client := managedclusters.NewManagedClustersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedClustersClient.AbortLatestOperation` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +if err := client.AbortLatestOperationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +payload := managedclusters.ManagedCluster{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, managedclusters.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +if err := client.DeleteThenPoll(ctx, id, managedclusters.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +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: `ManagedClustersClient.GetAccessProfile` + +```go +ctx := context.TODO() +id := managedclusters.NewAccessProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "accessProfileName") + +read, err := client.GetAccessProfile(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.GetCommandResult` + +```go +ctx := context.TODO() +id := managedclusters.NewCommandResultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "commandId") + +read, err := client.GetCommandResult(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.GetMeshRevisionProfile` + +```go +ctx := context.TODO() +id := managedclusters.NewMeshRevisionProfileID("12345678-1234-9876-4563-123456789012", "locationName", "meshRevisionProfileName") + +read, err := client.GetMeshRevisionProfile(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.GetMeshUpgradeProfile` + +```go +ctx := context.TODO() +id := managedclusters.NewMeshUpgradeProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "meshUpgradeProfileName") + +read, err := client.GetMeshUpgradeProfile(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.GetUpgradeProfile` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +read, err := client.GetUpgradeProfile(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.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: `ManagedClustersClient.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: `ManagedClustersClient.ListClusterAdminCredentials` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +read, err := client.ListClusterAdminCredentials(ctx, id, managedclusters.DefaultListClusterAdminCredentialsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.ListClusterMonitoringUserCredentials` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +read, err := client.ListClusterMonitoringUserCredentials(ctx, id, managedclusters.DefaultListClusterMonitoringUserCredentialsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.ListClusterUserCredentials` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +read, err := client.ListClusterUserCredentials(ctx, id, managedclusters.DefaultListClusterUserCredentialsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.ListKubernetesVersions` + +```go +ctx := context.TODO() +id := managedclusters.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +read, err := client.ListKubernetesVersions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.ListMeshRevisionProfiles` + +```go +ctx := context.TODO() +id := managedclusters.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.ListMeshRevisionProfiles(ctx, id)` can be used to do batched pagination +items, err := client.ListMeshRevisionProfilesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedClustersClient.ListMeshUpgradeProfiles` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +// alternatively `client.ListMeshUpgradeProfiles(ctx, id)` can be used to do batched pagination +items, err := client.ListMeshUpgradeProfilesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedClustersClient.ListOutboundNetworkDependenciesEndpoints` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +// alternatively `client.ListOutboundNetworkDependenciesEndpoints(ctx, id)` can be used to do batched pagination +items, err := client.ListOutboundNetworkDependenciesEndpointsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedClustersClient.ResetAADProfile` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +payload := managedclusters.ManagedClusterAADProfile{ + // ... +} + + +if err := client.ResetAADProfileThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.ResetServicePrincipalProfile` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +payload := managedclusters.ManagedClusterServicePrincipalProfile{ + // ... +} + + +if err := client.ResetServicePrincipalProfileThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.RotateClusterCertificates` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +if err := client.RotateClusterCertificatesThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.RotateServiceAccountSigningKeys` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +if err := client.RotateServiceAccountSigningKeysThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.RunCommand` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +payload := managedclusters.RunCommandRequest{ + // ... +} + + +if err := client.RunCommandThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.Start` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +if err := client.StartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.Stop` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +if err := client.StopThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.UpdateTags` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +payload := managedclusters.TagsObject{ + // ... +} + + +if err := client.UpdateTagsThenPoll(ctx, id, payload, managedclusters.DefaultUpdateTagsOperationOptions()); err != nil { + // handle the error +} +``` diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/client.go b/resource-manager/containerservice/2025-02-01/managedclusters/client.go new file mode 100644 index 00000000000..a2037a7e28b --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/client.go @@ -0,0 +1,26 @@ +package managedclusters + +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 ManagedClustersClient struct { + Client *resourcemanager.Client +} + +func NewManagedClustersClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedClustersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "managedclusters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedClustersClient: %+v", err) + } + + return &ManagedClustersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/constants.go b/resource-manager/containerservice/2025-02-01/managedclusters/constants.go new file mode 100644 index 00000000000..7f9ec066fea --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/constants.go @@ -0,0 +1,1681 @@ +package managedclusters + +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 AgentPoolMode string + +const ( + AgentPoolModeSystem AgentPoolMode = "System" + AgentPoolModeUser AgentPoolMode = "User" +) + +func PossibleValuesForAgentPoolMode() []string { + return []string{ + 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{ + "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 AgentPoolType string + +const ( + AgentPoolTypeAvailabilitySet AgentPoolType = "AvailabilitySet" + AgentPoolTypeVirtualMachineScaleSets AgentPoolType = "VirtualMachineScaleSets" +) + +func PossibleValuesForAgentPoolType() []string { + return []string{ + string(AgentPoolTypeAvailabilitySet), + string(AgentPoolTypeVirtualMachineScaleSets), + } +} + +func (s *AgentPoolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentPoolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentPoolType(input string) (*AgentPoolType, error) { + vals := map[string]AgentPoolType{ + "availabilityset": AgentPoolTypeAvailabilitySet, + "virtualmachinescalesets": AgentPoolTypeVirtualMachineScaleSets, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentPoolType(input) + return &out, nil +} + +type ArtifactSource string + +const ( + ArtifactSourceCache ArtifactSource = "Cache" + ArtifactSourceDirect ArtifactSource = "Direct" +) + +func PossibleValuesForArtifactSource() []string { + return []string{ + string(ArtifactSourceCache), + string(ArtifactSourceDirect), + } +} + +func (s *ArtifactSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseArtifactSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseArtifactSource(input string) (*ArtifactSource, error) { + vals := map[string]ArtifactSource{ + "cache": ArtifactSourceCache, + "direct": ArtifactSourceDirect, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ArtifactSource(input) + return &out, nil +} + +type BackendPoolType string + +const ( + BackendPoolTypeNodeIP BackendPoolType = "NodeIP" + BackendPoolTypeNodeIPConfiguration BackendPoolType = "NodeIPConfiguration" +) + +func PossibleValuesForBackendPoolType() []string { + return []string{ + string(BackendPoolTypeNodeIP), + string(BackendPoolTypeNodeIPConfiguration), + } +} + +func (s *BackendPoolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackendPoolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackendPoolType(input string) (*BackendPoolType, error) { + vals := map[string]BackendPoolType{ + "nodeip": BackendPoolTypeNodeIP, + "nodeipconfiguration": BackendPoolTypeNodeIPConfiguration, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackendPoolType(input) + return &out, nil +} + +type Code string + +const ( + CodeRunning Code = "Running" + CodeStopped Code = "Stopped" +) + +func PossibleValuesForCode() []string { + return []string{ + string(CodeRunning), + string(CodeStopped), + } +} + +func (s *Code) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCode(input string) (*Code, error) { + vals := map[string]Code{ + "running": CodeRunning, + "stopped": CodeStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Code(input) + return &out, nil +} + +type Expander string + +const ( + ExpanderLeastNegativewaste Expander = "least-waste" + ExpanderMostNegativepods Expander = "most-pods" + ExpanderPriority Expander = "priority" + ExpanderRandom Expander = "random" +) + +func PossibleValuesForExpander() []string { + return []string{ + string(ExpanderLeastNegativewaste), + string(ExpanderMostNegativepods), + string(ExpanderPriority), + string(ExpanderRandom), + } +} + +func (s *Expander) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpander(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpander(input string) (*Expander, error) { + vals := map[string]Expander{ + "least-waste": ExpanderLeastNegativewaste, + "most-pods": ExpanderMostNegativepods, + "priority": ExpanderPriority, + "random": ExpanderRandom, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Expander(input) + return &out, nil +} + +type Format string + +const ( + FormatAzure Format = "azure" + FormatExec Format = "exec" +) + +func PossibleValuesForFormat() []string { + return []string{ + string(FormatAzure), + string(FormatExec), + } +} + +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{ + "azure": FormatAzure, + "exec": FormatExec, + } + 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 GPUDriver string + +const ( + GPUDriverInstall GPUDriver = "Install" + GPUDriverNone GPUDriver = "None" +) + +func PossibleValuesForGPUDriver() []string { + return []string{ + string(GPUDriverInstall), + string(GPUDriverNone), + } +} + +func (s *GPUDriver) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGPUDriver(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGPUDriver(input string) (*GPUDriver, error) { + vals := map[string]GPUDriver{ + "install": GPUDriverInstall, + "none": GPUDriverNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GPUDriver(input) + return &out, nil +} + +type GPUInstanceProfile string + +const ( + GPUInstanceProfileMIGFourg GPUInstanceProfile = "MIG4g" + GPUInstanceProfileMIGOneg GPUInstanceProfile = "MIG1g" + GPUInstanceProfileMIGSeveng GPUInstanceProfile = "MIG7g" + GPUInstanceProfileMIGThreeg GPUInstanceProfile = "MIG3g" + GPUInstanceProfileMIGTwog GPUInstanceProfile = "MIG2g" +) + +func PossibleValuesForGPUInstanceProfile() []string { + return []string{ + string(GPUInstanceProfileMIGFourg), + string(GPUInstanceProfileMIGOneg), + string(GPUInstanceProfileMIGSeveng), + string(GPUInstanceProfileMIGThreeg), + string(GPUInstanceProfileMIGTwog), + } +} + +func (s *GPUInstanceProfile) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGPUInstanceProfile(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGPUInstanceProfile(input string) (*GPUInstanceProfile, error) { + vals := map[string]GPUInstanceProfile{ + "mig4g": GPUInstanceProfileMIGFourg, + "mig1g": GPUInstanceProfileMIGOneg, + "mig7g": GPUInstanceProfileMIGSeveng, + "mig3g": GPUInstanceProfileMIGThreeg, + "mig2g": GPUInstanceProfileMIGTwog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GPUInstanceProfile(input) + return &out, nil +} + +type IPFamily string + +const ( + IPFamilyIPvFour IPFamily = "IPv4" + IPFamilyIPvSix IPFamily = "IPv6" +) + +func PossibleValuesForIPFamily() []string { + return []string{ + string(IPFamilyIPvFour), + string(IPFamilyIPvSix), + } +} + +func (s *IPFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPFamily(input string) (*IPFamily, error) { + vals := map[string]IPFamily{ + "ipv4": IPFamilyIPvFour, + "ipv6": IPFamilyIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPFamily(input) + return &out, nil +} + +type IstioIngressGatewayMode string + +const ( + IstioIngressGatewayModeExternal IstioIngressGatewayMode = "External" + IstioIngressGatewayModeInternal IstioIngressGatewayMode = "Internal" +) + +func PossibleValuesForIstioIngressGatewayMode() []string { + return []string{ + string(IstioIngressGatewayModeExternal), + string(IstioIngressGatewayModeInternal), + } +} + +func (s *IstioIngressGatewayMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIstioIngressGatewayMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIstioIngressGatewayMode(input string) (*IstioIngressGatewayMode, error) { + vals := map[string]IstioIngressGatewayMode{ + "external": IstioIngressGatewayModeExternal, + "internal": IstioIngressGatewayModeInternal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IstioIngressGatewayMode(input) + return &out, nil +} + +type KeyVaultNetworkAccessTypes string + +const ( + KeyVaultNetworkAccessTypesPrivate KeyVaultNetworkAccessTypes = "Private" + KeyVaultNetworkAccessTypesPublic KeyVaultNetworkAccessTypes = "Public" +) + +func PossibleValuesForKeyVaultNetworkAccessTypes() []string { + return []string{ + string(KeyVaultNetworkAccessTypesPrivate), + string(KeyVaultNetworkAccessTypesPublic), + } +} + +func (s *KeyVaultNetworkAccessTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultNetworkAccessTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyVaultNetworkAccessTypes(input string) (*KeyVaultNetworkAccessTypes, error) { + vals := map[string]KeyVaultNetworkAccessTypes{ + "private": KeyVaultNetworkAccessTypesPrivate, + "public": KeyVaultNetworkAccessTypesPublic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyVaultNetworkAccessTypes(input) + return &out, nil +} + +type KubeletDiskType string + +const ( + KubeletDiskTypeOS KubeletDiskType = "OS" + KubeletDiskTypeTemporary KubeletDiskType = "Temporary" +) + +func PossibleValuesForKubeletDiskType() []string { + return []string{ + string(KubeletDiskTypeOS), + string(KubeletDiskTypeTemporary), + } +} + +func (s *KubeletDiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubeletDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubeletDiskType(input string) (*KubeletDiskType, error) { + vals := map[string]KubeletDiskType{ + "os": KubeletDiskTypeOS, + "temporary": KubeletDiskTypeTemporary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubeletDiskType(input) + return &out, nil +} + +type KubernetesSupportPlan string + +const ( + KubernetesSupportPlanAKSLongTermSupport KubernetesSupportPlan = "AKSLongTermSupport" + KubernetesSupportPlanKubernetesOfficial KubernetesSupportPlan = "KubernetesOfficial" +) + +func PossibleValuesForKubernetesSupportPlan() []string { + return []string{ + string(KubernetesSupportPlanAKSLongTermSupport), + string(KubernetesSupportPlanKubernetesOfficial), + } +} + +func (s *KubernetesSupportPlan) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubernetesSupportPlan(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubernetesSupportPlan(input string) (*KubernetesSupportPlan, error) { + vals := map[string]KubernetesSupportPlan{ + "akslongtermsupport": KubernetesSupportPlanAKSLongTermSupport, + "kubernetesofficial": KubernetesSupportPlanKubernetesOfficial, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubernetesSupportPlan(input) + return &out, nil +} + +type LicenseType string + +const ( + LicenseTypeNone LicenseType = "None" + LicenseTypeWindowsServer LicenseType = "Windows_Server" +) + +func PossibleValuesForLicenseType() []string { + return []string{ + string(LicenseTypeNone), + string(LicenseTypeWindowsServer), + } +} + +func (s *LicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLicenseType(input string) (*LicenseType, error) { + vals := map[string]LicenseType{ + "none": LicenseTypeNone, + "windows_server": LicenseTypeWindowsServer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LicenseType(input) + return &out, nil +} + +type LoadBalancerSku string + +const ( + LoadBalancerSkuBasic LoadBalancerSku = "basic" + LoadBalancerSkuStandard LoadBalancerSku = "standard" +) + +func PossibleValuesForLoadBalancerSku() []string { + return []string{ + string(LoadBalancerSkuBasic), + string(LoadBalancerSkuStandard), + } +} + +func (s *LoadBalancerSku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerSku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerSku(input string) (*LoadBalancerSku, error) { + vals := map[string]LoadBalancerSku{ + "basic": LoadBalancerSkuBasic, + "standard": LoadBalancerSkuStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerSku(input) + return &out, nil +} + +type ManagedClusterPodIdentityProvisioningState string + +const ( + ManagedClusterPodIdentityProvisioningStateAssigned ManagedClusterPodIdentityProvisioningState = "Assigned" + ManagedClusterPodIdentityProvisioningStateCanceled ManagedClusterPodIdentityProvisioningState = "Canceled" + ManagedClusterPodIdentityProvisioningStateDeleting ManagedClusterPodIdentityProvisioningState = "Deleting" + ManagedClusterPodIdentityProvisioningStateFailed ManagedClusterPodIdentityProvisioningState = "Failed" + ManagedClusterPodIdentityProvisioningStateSucceeded ManagedClusterPodIdentityProvisioningState = "Succeeded" + ManagedClusterPodIdentityProvisioningStateUpdating ManagedClusterPodIdentityProvisioningState = "Updating" +) + +func PossibleValuesForManagedClusterPodIdentityProvisioningState() []string { + return []string{ + string(ManagedClusterPodIdentityProvisioningStateAssigned), + string(ManagedClusterPodIdentityProvisioningStateCanceled), + string(ManagedClusterPodIdentityProvisioningStateDeleting), + string(ManagedClusterPodIdentityProvisioningStateFailed), + string(ManagedClusterPodIdentityProvisioningStateSucceeded), + string(ManagedClusterPodIdentityProvisioningStateUpdating), + } +} + +func (s *ManagedClusterPodIdentityProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedClusterPodIdentityProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedClusterPodIdentityProvisioningState(input string) (*ManagedClusterPodIdentityProvisioningState, error) { + vals := map[string]ManagedClusterPodIdentityProvisioningState{ + "assigned": ManagedClusterPodIdentityProvisioningStateAssigned, + "canceled": ManagedClusterPodIdentityProvisioningStateCanceled, + "deleting": ManagedClusterPodIdentityProvisioningStateDeleting, + "failed": ManagedClusterPodIdentityProvisioningStateFailed, + "succeeded": ManagedClusterPodIdentityProvisioningStateSucceeded, + "updating": ManagedClusterPodIdentityProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedClusterPodIdentityProvisioningState(input) + return &out, nil +} + +type ManagedClusterSKUName string + +const ( + ManagedClusterSKUNameBase ManagedClusterSKUName = "Base" +) + +func PossibleValuesForManagedClusterSKUName() []string { + return []string{ + string(ManagedClusterSKUNameBase), + } +} + +func (s *ManagedClusterSKUName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedClusterSKUName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedClusterSKUName(input string) (*ManagedClusterSKUName, error) { + vals := map[string]ManagedClusterSKUName{ + "base": ManagedClusterSKUNameBase, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedClusterSKUName(input) + return &out, nil +} + +type ManagedClusterSKUTier string + +const ( + ManagedClusterSKUTierFree ManagedClusterSKUTier = "Free" + ManagedClusterSKUTierPremium ManagedClusterSKUTier = "Premium" + ManagedClusterSKUTierStandard ManagedClusterSKUTier = "Standard" +) + +func PossibleValuesForManagedClusterSKUTier() []string { + return []string{ + string(ManagedClusterSKUTierFree), + string(ManagedClusterSKUTierPremium), + string(ManagedClusterSKUTierStandard), + } +} + +func (s *ManagedClusterSKUTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedClusterSKUTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedClusterSKUTier(input string) (*ManagedClusterSKUTier, error) { + vals := map[string]ManagedClusterSKUTier{ + "free": ManagedClusterSKUTierFree, + "premium": ManagedClusterSKUTierPremium, + "standard": ManagedClusterSKUTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedClusterSKUTier(input) + return &out, nil +} + +type NetworkDataplane string + +const ( + NetworkDataplaneAzure NetworkDataplane = "azure" + NetworkDataplaneCilium NetworkDataplane = "cilium" +) + +func PossibleValuesForNetworkDataplane() []string { + return []string{ + string(NetworkDataplaneAzure), + string(NetworkDataplaneCilium), + } +} + +func (s *NetworkDataplane) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkDataplane(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkDataplane(input string) (*NetworkDataplane, error) { + vals := map[string]NetworkDataplane{ + "azure": NetworkDataplaneAzure, + "cilium": NetworkDataplaneCilium, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkDataplane(input) + return &out, nil +} + +type NetworkMode string + +const ( + NetworkModeBridge NetworkMode = "bridge" + NetworkModeTransparent NetworkMode = "transparent" +) + +func PossibleValuesForNetworkMode() []string { + return []string{ + string(NetworkModeBridge), + string(NetworkModeTransparent), + } +} + +func (s *NetworkMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkMode(input string) (*NetworkMode, error) { + vals := map[string]NetworkMode{ + "bridge": NetworkModeBridge, + "transparent": NetworkModeTransparent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkMode(input) + return &out, nil +} + +type NetworkPlugin string + +const ( + NetworkPluginAzure NetworkPlugin = "azure" + NetworkPluginKubenet NetworkPlugin = "kubenet" + NetworkPluginNone NetworkPlugin = "none" +) + +func PossibleValuesForNetworkPlugin() []string { + return []string{ + string(NetworkPluginAzure), + string(NetworkPluginKubenet), + string(NetworkPluginNone), + } +} + +func (s *NetworkPlugin) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkPlugin(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkPlugin(input string) (*NetworkPlugin, error) { + vals := map[string]NetworkPlugin{ + "azure": NetworkPluginAzure, + "kubenet": NetworkPluginKubenet, + "none": NetworkPluginNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkPlugin(input) + return &out, nil +} + +type NetworkPluginMode string + +const ( + NetworkPluginModeOverlay NetworkPluginMode = "overlay" +) + +func PossibleValuesForNetworkPluginMode() []string { + return []string{ + string(NetworkPluginModeOverlay), + } +} + +func (s *NetworkPluginMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkPluginMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkPluginMode(input string) (*NetworkPluginMode, error) { + vals := map[string]NetworkPluginMode{ + "overlay": NetworkPluginModeOverlay, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkPluginMode(input) + return &out, nil +} + +type NetworkPolicy string + +const ( + NetworkPolicyAzure NetworkPolicy = "azure" + NetworkPolicyCalico NetworkPolicy = "calico" + NetworkPolicyCilium NetworkPolicy = "cilium" + NetworkPolicyNone NetworkPolicy = "none" +) + +func PossibleValuesForNetworkPolicy() []string { + return []string{ + string(NetworkPolicyAzure), + string(NetworkPolicyCalico), + string(NetworkPolicyCilium), + string(NetworkPolicyNone), + } +} + +func (s *NetworkPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkPolicy(input string) (*NetworkPolicy, error) { + vals := map[string]NetworkPolicy{ + "azure": NetworkPolicyAzure, + "calico": NetworkPolicyCalico, + "cilium": NetworkPolicyCilium, + "none": NetworkPolicyNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkPolicy(input) + return &out, nil +} + +type NginxIngressControllerType string + +const ( + NginxIngressControllerTypeAnnotationControlled NginxIngressControllerType = "AnnotationControlled" + NginxIngressControllerTypeExternal NginxIngressControllerType = "External" + NginxIngressControllerTypeInternal NginxIngressControllerType = "Internal" + NginxIngressControllerTypeNone NginxIngressControllerType = "None" +) + +func PossibleValuesForNginxIngressControllerType() []string { + return []string{ + string(NginxIngressControllerTypeAnnotationControlled), + string(NginxIngressControllerTypeExternal), + string(NginxIngressControllerTypeInternal), + string(NginxIngressControllerTypeNone), + } +} + +func (s *NginxIngressControllerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNginxIngressControllerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNginxIngressControllerType(input string) (*NginxIngressControllerType, error) { + vals := map[string]NginxIngressControllerType{ + "annotationcontrolled": NginxIngressControllerTypeAnnotationControlled, + "external": NginxIngressControllerTypeExternal, + "internal": NginxIngressControllerTypeInternal, + "none": NginxIngressControllerTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NginxIngressControllerType(input) + return &out, nil +} + +type NodeOSUpgradeChannel string + +const ( + NodeOSUpgradeChannelNodeImage NodeOSUpgradeChannel = "NodeImage" + NodeOSUpgradeChannelNone NodeOSUpgradeChannel = "None" + NodeOSUpgradeChannelSecurityPatch NodeOSUpgradeChannel = "SecurityPatch" + NodeOSUpgradeChannelUnmanaged NodeOSUpgradeChannel = "Unmanaged" +) + +func PossibleValuesForNodeOSUpgradeChannel() []string { + return []string{ + string(NodeOSUpgradeChannelNodeImage), + string(NodeOSUpgradeChannelNone), + string(NodeOSUpgradeChannelSecurityPatch), + string(NodeOSUpgradeChannelUnmanaged), + } +} + +func (s *NodeOSUpgradeChannel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNodeOSUpgradeChannel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNodeOSUpgradeChannel(input string) (*NodeOSUpgradeChannel, error) { + vals := map[string]NodeOSUpgradeChannel{ + "nodeimage": NodeOSUpgradeChannelNodeImage, + "none": NodeOSUpgradeChannelNone, + "securitypatch": NodeOSUpgradeChannelSecurityPatch, + "unmanaged": NodeOSUpgradeChannelUnmanaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NodeOSUpgradeChannel(input) + return &out, nil +} + +type OSDiskType string + +const ( + OSDiskTypeEphemeral OSDiskType = "Ephemeral" + OSDiskTypeManaged OSDiskType = "Managed" +) + +func PossibleValuesForOSDiskType() []string { + return []string{ + string(OSDiskTypeEphemeral), + string(OSDiskTypeManaged), + } +} + +func (s *OSDiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSDiskType(input string) (*OSDiskType, error) { + vals := map[string]OSDiskType{ + "ephemeral": OSDiskTypeEphemeral, + "managed": OSDiskTypeManaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSDiskType(input) + return &out, nil +} + +type OSSKU string + +const ( + OSSKUAzureLinux OSSKU = "AzureLinux" + OSSKUCBLMariner OSSKU = "CBLMariner" + OSSKUUbuntu OSSKU = "Ubuntu" + OSSKUWindowsTwoZeroOneNine OSSKU = "Windows2019" + OSSKUWindowsTwoZeroTwoTwo OSSKU = "Windows2022" +) + +func PossibleValuesForOSSKU() []string { + return []string{ + string(OSSKUAzureLinux), + string(OSSKUCBLMariner), + string(OSSKUUbuntu), + string(OSSKUWindowsTwoZeroOneNine), + string(OSSKUWindowsTwoZeroTwoTwo), + } +} + +func (s *OSSKU) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSSKU(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSSKU(input string) (*OSSKU, error) { + vals := map[string]OSSKU{ + "azurelinux": OSSKUAzureLinux, + "cblmariner": OSSKUCBLMariner, + "ubuntu": OSSKUUbuntu, + "windows2019": OSSKUWindowsTwoZeroOneNine, + "windows2022": OSSKUWindowsTwoZeroTwoTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSSKU(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 OutboundType string + +const ( + OutboundTypeLoadBalancer OutboundType = "loadBalancer" + OutboundTypeManagedNATGateway OutboundType = "managedNATGateway" + OutboundTypeNone OutboundType = "none" + OutboundTypeUserAssignedNATGateway OutboundType = "userAssignedNATGateway" + OutboundTypeUserDefinedRouting OutboundType = "userDefinedRouting" +) + +func PossibleValuesForOutboundType() []string { + return []string{ + string(OutboundTypeLoadBalancer), + string(OutboundTypeManagedNATGateway), + string(OutboundTypeNone), + string(OutboundTypeUserAssignedNATGateway), + string(OutboundTypeUserDefinedRouting), + } +} + +func (s *OutboundType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOutboundType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOutboundType(input string) (*OutboundType, error) { + vals := map[string]OutboundType{ + "loadbalancer": OutboundTypeLoadBalancer, + "managednatgateway": OutboundTypeManagedNATGateway, + "none": OutboundTypeNone, + "userassignednatgateway": OutboundTypeUserAssignedNATGateway, + "userdefinedrouting": OutboundTypeUserDefinedRouting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OutboundType(input) + return &out, nil +} + +type Protocol string + +const ( + ProtocolTCP Protocol = "TCP" + ProtocolUDP Protocol = "UDP" +) + +func PossibleValuesForProtocol() []string { + return []string{ + string(ProtocolTCP), + string(ProtocolUDP), + } +} + +func (s *Protocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtocol(input string) (*Protocol, error) { + vals := map[string]Protocol{ + "tcp": ProtocolTCP, + "udp": ProtocolUDP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Protocol(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 RestrictionLevel string + +const ( + RestrictionLevelReadOnly RestrictionLevel = "ReadOnly" + RestrictionLevelUnrestricted RestrictionLevel = "Unrestricted" +) + +func PossibleValuesForRestrictionLevel() []string { + return []string{ + string(RestrictionLevelReadOnly), + string(RestrictionLevelUnrestricted), + } +} + +func (s *RestrictionLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRestrictionLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRestrictionLevel(input string) (*RestrictionLevel, error) { + vals := map[string]RestrictionLevel{ + "readonly": RestrictionLevelReadOnly, + "unrestricted": RestrictionLevelUnrestricted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestrictionLevel(input) + return &out, nil +} + +type ScaleDownMode string + +const ( + ScaleDownModeDeallocate ScaleDownMode = "Deallocate" + ScaleDownModeDelete ScaleDownMode = "Delete" +) + +func PossibleValuesForScaleDownMode() []string { + return []string{ + string(ScaleDownModeDeallocate), + string(ScaleDownModeDelete), + } +} + +func (s *ScaleDownMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleDownMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleDownMode(input string) (*ScaleDownMode, error) { + vals := map[string]ScaleDownMode{ + "deallocate": ScaleDownModeDeallocate, + "delete": ScaleDownModeDelete, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleDownMode(input) + return &out, nil +} + +type ScaleSetEvictionPolicy string + +const ( + ScaleSetEvictionPolicyDeallocate ScaleSetEvictionPolicy = "Deallocate" + ScaleSetEvictionPolicyDelete ScaleSetEvictionPolicy = "Delete" +) + +func PossibleValuesForScaleSetEvictionPolicy() []string { + return []string{ + string(ScaleSetEvictionPolicyDeallocate), + string(ScaleSetEvictionPolicyDelete), + } +} + +func (s *ScaleSetEvictionPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleSetEvictionPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleSetEvictionPolicy(input string) (*ScaleSetEvictionPolicy, error) { + vals := map[string]ScaleSetEvictionPolicy{ + "deallocate": ScaleSetEvictionPolicyDeallocate, + "delete": ScaleSetEvictionPolicyDelete, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleSetEvictionPolicy(input) + return &out, nil +} + +type ScaleSetPriority string + +const ( + ScaleSetPriorityRegular ScaleSetPriority = "Regular" + ScaleSetPrioritySpot ScaleSetPriority = "Spot" +) + +func PossibleValuesForScaleSetPriority() []string { + return []string{ + string(ScaleSetPriorityRegular), + string(ScaleSetPrioritySpot), + } +} + +func (s *ScaleSetPriority) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleSetPriority(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleSetPriority(input string) (*ScaleSetPriority, error) { + vals := map[string]ScaleSetPriority{ + "regular": ScaleSetPriorityRegular, + "spot": ScaleSetPrioritySpot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleSetPriority(input) + return &out, nil +} + +type ServiceMeshMode string + +const ( + ServiceMeshModeDisabled ServiceMeshMode = "Disabled" + ServiceMeshModeIstio ServiceMeshMode = "Istio" +) + +func PossibleValuesForServiceMeshMode() []string { + return []string{ + string(ServiceMeshModeDisabled), + string(ServiceMeshModeIstio), + } +} + +func (s *ServiceMeshMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceMeshMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceMeshMode(input string) (*ServiceMeshMode, error) { + vals := map[string]ServiceMeshMode{ + "disabled": ServiceMeshModeDisabled, + "istio": ServiceMeshModeIstio, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceMeshMode(input) + return &out, nil +} + +type UpgradeChannel string + +const ( + UpgradeChannelNodeNegativeimage UpgradeChannel = "node-image" + UpgradeChannelNone UpgradeChannel = "none" + UpgradeChannelPatch UpgradeChannel = "patch" + UpgradeChannelRapid UpgradeChannel = "rapid" + UpgradeChannelStable UpgradeChannel = "stable" +) + +func PossibleValuesForUpgradeChannel() []string { + return []string{ + string(UpgradeChannelNodeNegativeimage), + string(UpgradeChannelNone), + string(UpgradeChannelPatch), + string(UpgradeChannelRapid), + string(UpgradeChannelStable), + } +} + +func (s *UpgradeChannel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradeChannel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradeChannel(input string) (*UpgradeChannel, error) { + vals := map[string]UpgradeChannel{ + "node-image": UpgradeChannelNodeNegativeimage, + "none": UpgradeChannelNone, + "patch": UpgradeChannelPatch, + "rapid": UpgradeChannelRapid, + "stable": UpgradeChannelStable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradeChannel(input) + return &out, nil +} + +type WorkloadRuntime string + +const ( + WorkloadRuntimeOCIContainer WorkloadRuntime = "OCIContainer" + WorkloadRuntimeWasmWasi WorkloadRuntime = "WasmWasi" +) + +func PossibleValuesForWorkloadRuntime() []string { + return []string{ + string(WorkloadRuntimeOCIContainer), + string(WorkloadRuntimeWasmWasi), + } +} + +func (s *WorkloadRuntime) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkloadRuntime(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkloadRuntime(input string) (*WorkloadRuntime, error) { + vals := map[string]WorkloadRuntime{ + "ocicontainer": WorkloadRuntimeOCIContainer, + "wasmwasi": WorkloadRuntimeWasmWasi, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadRuntime(input) + return &out, nil +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/id_accessprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/id_accessprofile.go new file mode 100644 index 00000000000..0cc903a7fde --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/id_accessprofile.go @@ -0,0 +1,139 @@ +package managedclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AccessProfileId{}) +} + +var _ resourceids.ResourceId = &AccessProfileId{} + +// AccessProfileId is a struct representing the Resource ID for a Access Profile +type AccessProfileId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + AccessProfileName string +} + +// NewAccessProfileID returns a new AccessProfileId struct +func NewAccessProfileID(subscriptionId string, resourceGroupName string, managedClusterName string, accessProfileName string) AccessProfileId { + return AccessProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + AccessProfileName: accessProfileName, + } +} + +// ParseAccessProfileID parses 'input' into a AccessProfileId +func ParseAccessProfileID(input string) (*AccessProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccessProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccessProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAccessProfileIDInsensitively parses 'input' case-insensitively into a AccessProfileId +// note: this method should only be used for API response data and not user input +func ParseAccessProfileIDInsensitively(input string) (*AccessProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccessProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccessProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AccessProfileId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.AccessProfileName, ok = input.Parsed["accessProfileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "accessProfileName", input) + } + + return nil +} + +// ValidateAccessProfileID checks that 'input' can be parsed as a Access Profile ID +func ValidateAccessProfileID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAccessProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Access Profile ID +func (id AccessProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/accessProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.AccessProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Access Profile ID +func (id AccessProfileId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterName"), + resourceids.StaticSegment("staticAccessProfiles", "accessProfiles", "accessProfiles"), + resourceids.UserSpecifiedSegment("accessProfileName", "accessProfileName"), + } +} + +// String returns a human-readable description of this Access Profile ID +func (id AccessProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Access Profile Name: %q", id.AccessProfileName), + } + return fmt.Sprintf("Access Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/id_accessprofile_test.go b/resource-manager/containerservice/2025-02-01/managedclusters/id_accessprofile_test.go new file mode 100644 index 00000000000..9d2f96670dd --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/id_accessprofile_test.go @@ -0,0 +1,327 @@ +package managedclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AccessProfileId{} + +func TestNewAccessProfileID(t *testing.T) { + id := NewAccessProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "accessProfileName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterName") + } + + if id.AccessProfileName != "accessProfileName" { + t.Fatalf("Expected %q but got %q for Segment 'AccessProfileName'", id.AccessProfileName, "accessProfileName") + } +} + +func TestFormatAccessProfileID(t *testing.T) { + actual := NewAccessProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "accessProfileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/accessProfiles/accessProfileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAccessProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AccessProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/accessProfiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/accessProfiles/accessProfileName", + Expected: &AccessProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + AccessProfileName: "accessProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/accessProfiles/accessProfileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAccessProfileID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.AccessProfileName != v.Expected.AccessProfileName { + t.Fatalf("Expected %q but got %q for AccessProfileName", v.Expected.AccessProfileName, actual.AccessProfileName) + } + + } +} + +func TestParseAccessProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AccessProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/accessProfiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/aCcEsSpRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/accessProfiles/accessProfileName", + Expected: &AccessProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + AccessProfileName: "accessProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/accessProfiles/accessProfileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/aCcEsSpRoFiLeS/aCcEsSpRoFiLeNaMe", + Expected: &AccessProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRnAmE", + AccessProfileName: "aCcEsSpRoFiLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/aCcEsSpRoFiLeS/aCcEsSpRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAccessProfileIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.AccessProfileName != v.Expected.AccessProfileName { + t.Fatalf("Expected %q but got %q for AccessProfileName", v.Expected.AccessProfileName, actual.AccessProfileName) + } + + } +} + +func TestSegmentsForAccessProfileId(t *testing.T) { + segments := AccessProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AccessProfileId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/id_commandresult.go b/resource-manager/containerservice/2025-02-01/managedclusters/id_commandresult.go new file mode 100644 index 00000000000..737a71e0621 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/id_commandresult.go @@ -0,0 +1,139 @@ +package managedclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CommandResultId{}) +} + +var _ resourceids.ResourceId = &CommandResultId{} + +// CommandResultId is a struct representing the Resource ID for a Command Result +type CommandResultId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + CommandId string +} + +// NewCommandResultID returns a new CommandResultId struct +func NewCommandResultID(subscriptionId string, resourceGroupName string, managedClusterName string, commandId string) CommandResultId { + return CommandResultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + CommandId: commandId, + } +} + +// ParseCommandResultID parses 'input' into a CommandResultId +func ParseCommandResultID(input string) (*CommandResultId, error) { + parser := resourceids.NewParserFromResourceIdType(&CommandResultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CommandResultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCommandResultIDInsensitively parses 'input' case-insensitively into a CommandResultId +// note: this method should only be used for API response data and not user input +func ParseCommandResultIDInsensitively(input string) (*CommandResultId, error) { + parser := resourceids.NewParserFromResourceIdType(&CommandResultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CommandResultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CommandResultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.CommandId, ok = input.Parsed["commandId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "commandId", input) + } + + return nil +} + +// ValidateCommandResultID checks that 'input' can be parsed as a Command Result ID +func ValidateCommandResultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCommandResultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Command Result ID +func (id CommandResultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/commandResults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.CommandId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Command Result ID +func (id CommandResultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterName"), + resourceids.StaticSegment("staticCommandResults", "commandResults", "commandResults"), + resourceids.UserSpecifiedSegment("commandId", "commandId"), + } +} + +// String returns a human-readable description of this Command Result ID +func (id CommandResultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Command: %q", id.CommandId), + } + return fmt.Sprintf("Command Result (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/id_commandresult_test.go b/resource-manager/containerservice/2025-02-01/managedclusters/id_commandresult_test.go new file mode 100644 index 00000000000..0c55ce098fa --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/id_commandresult_test.go @@ -0,0 +1,327 @@ +package managedclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CommandResultId{} + +func TestNewCommandResultID(t *testing.T) { + id := NewCommandResultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "commandId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterName") + } + + if id.CommandId != "commandId" { + t.Fatalf("Expected %q but got %q for Segment 'CommandId'", id.CommandId, "commandId") + } +} + +func TestFormatCommandResultID(t *testing.T) { + actual := NewCommandResultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "commandId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/commandResults/commandId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCommandResultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CommandResultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/commandResults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/commandResults/commandId", + Expected: &CommandResultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + CommandId: "commandId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/commandResults/commandId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCommandResultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.CommandId != v.Expected.CommandId { + t.Fatalf("Expected %q but got %q for CommandId", v.Expected.CommandId, actual.CommandId) + } + + } +} + +func TestParseCommandResultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CommandResultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/commandResults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/cOmMaNdReSuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/commandResults/commandId", + Expected: &CommandResultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + CommandId: "commandId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/commandResults/commandId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/cOmMaNdReSuLtS/cOmMaNdId", + Expected: &CommandResultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRnAmE", + CommandId: "cOmMaNdId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/cOmMaNdReSuLtS/cOmMaNdId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCommandResultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.CommandId != v.Expected.CommandId { + t.Fatalf("Expected %q but got %q for CommandId", v.Expected.CommandId, actual.CommandId) + } + + } +} + +func TestSegmentsForCommandResultId(t *testing.T) { + segments := CommandResultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CommandResultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/id_location.go b/resource-manager/containerservice/2025-02-01/managedclusters/id_location.go new file mode 100644 index 00000000000..79aa9b51c07 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/id_location.go @@ -0,0 +1,121 @@ +package managedclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) 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.ContainerService/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("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + 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/containerservice/2025-02-01/managedclusters/id_location_test.go b/resource-manager/containerservice/2025-02-01/managedclusters/id_location_test.go new file mode 100644 index 00000000000..db0f4f67412 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/id_location_test.go @@ -0,0 +1,237 @@ +package managedclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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.ContainerService/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.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/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.ContainerService/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.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/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.ContainerService/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/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.cOnTaInErSeRvIcE/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/containerservice/2025-02-01/managedclusters/id_meshrevisionprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/id_meshrevisionprofile.go new file mode 100644 index 00000000000..009771d0a59 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/id_meshrevisionprofile.go @@ -0,0 +1,130 @@ +package managedclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MeshRevisionProfileId{}) +} + +var _ resourceids.ResourceId = &MeshRevisionProfileId{} + +// MeshRevisionProfileId is a struct representing the Resource ID for a Mesh Revision Profile +type MeshRevisionProfileId struct { + SubscriptionId string + LocationName string + MeshRevisionProfileName string +} + +// NewMeshRevisionProfileID returns a new MeshRevisionProfileId struct +func NewMeshRevisionProfileID(subscriptionId string, locationName string, meshRevisionProfileName string) MeshRevisionProfileId { + return MeshRevisionProfileId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + MeshRevisionProfileName: meshRevisionProfileName, + } +} + +// ParseMeshRevisionProfileID parses 'input' into a MeshRevisionProfileId +func ParseMeshRevisionProfileID(input string) (*MeshRevisionProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&MeshRevisionProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MeshRevisionProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMeshRevisionProfileIDInsensitively parses 'input' case-insensitively into a MeshRevisionProfileId +// note: this method should only be used for API response data and not user input +func ParseMeshRevisionProfileIDInsensitively(input string) (*MeshRevisionProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&MeshRevisionProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MeshRevisionProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MeshRevisionProfileId) 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.MeshRevisionProfileName, ok = input.Parsed["meshRevisionProfileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "meshRevisionProfileName", input) + } + + return nil +} + +// ValidateMeshRevisionProfileID checks that 'input' can be parsed as a Mesh Revision Profile ID +func ValidateMeshRevisionProfileID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseMeshRevisionProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mesh Revision Profile ID +func (id MeshRevisionProfileId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.ContainerService/locations/%s/meshRevisionProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.MeshRevisionProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mesh Revision Profile ID +func (id MeshRevisionProfileId) 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("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + resourceids.StaticSegment("staticMeshRevisionProfiles", "meshRevisionProfiles", "meshRevisionProfiles"), + resourceids.UserSpecifiedSegment("meshRevisionProfileName", "meshRevisionProfileName"), + } +} + +// String returns a human-readable description of this Mesh Revision Profile ID +func (id MeshRevisionProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Mesh Revision Profile Name: %q", id.MeshRevisionProfileName), + } + return fmt.Sprintf("Mesh Revision Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/id_meshrevisionprofile_test.go b/resource-manager/containerservice/2025-02-01/managedclusters/id_meshrevisionprofile_test.go new file mode 100644 index 00000000000..a4e7a52ef61 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/id_meshrevisionprofile_test.go @@ -0,0 +1,282 @@ +package managedclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MeshRevisionProfileId{} + +func TestNewMeshRevisionProfileID(t *testing.T) { + id := NewMeshRevisionProfileID("12345678-1234-9876-4563-123456789012", "locationName", "meshRevisionProfileName") + + if id.SubscriptionId != "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.MeshRevisionProfileName != "meshRevisionProfileName" { + t.Fatalf("Expected %q but got %q for Segment 'MeshRevisionProfileName'", id.MeshRevisionProfileName, "meshRevisionProfileName") + } +} + +func TestFormatMeshRevisionProfileID(t *testing.T) { + actual := NewMeshRevisionProfileID("12345678-1234-9876-4563-123456789012", "locationName", "meshRevisionProfileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationName/meshRevisionProfiles/meshRevisionProfileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMeshRevisionProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MeshRevisionProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + 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.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationName/meshRevisionProfiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationName/meshRevisionProfiles/meshRevisionProfileName", + Expected: &MeshRevisionProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + MeshRevisionProfileName: "meshRevisionProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationName/meshRevisionProfiles/meshRevisionProfileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMeshRevisionProfileID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't 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.MeshRevisionProfileName != v.Expected.MeshRevisionProfileName { + t.Fatalf("Expected %q but got %q for MeshRevisionProfileName", v.Expected.MeshRevisionProfileName, actual.MeshRevisionProfileName) + } + + } +} + +func TestParseMeshRevisionProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MeshRevisionProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (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.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationName/meshRevisionProfiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNnAmE/mEsHrEvIsIoNpRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationName/meshRevisionProfiles/meshRevisionProfileName", + Expected: &MeshRevisionProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + MeshRevisionProfileName: "meshRevisionProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationName/meshRevisionProfiles/meshRevisionProfileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNnAmE/mEsHrEvIsIoNpRoFiLeS/mEsHrEvIsIoNpRoFiLeNaMe", + Expected: &MeshRevisionProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + MeshRevisionProfileName: "mEsHrEvIsIoNpRoFiLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNnAmE/mEsHrEvIsIoNpRoFiLeS/mEsHrEvIsIoNpRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMeshRevisionProfileIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't 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.MeshRevisionProfileName != v.Expected.MeshRevisionProfileName { + t.Fatalf("Expected %q but got %q for MeshRevisionProfileName", v.Expected.MeshRevisionProfileName, actual.MeshRevisionProfileName) + } + + } +} + +func TestSegmentsForMeshRevisionProfileId(t *testing.T) { + segments := MeshRevisionProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MeshRevisionProfileId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/id_meshupgradeprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/id_meshupgradeprofile.go new file mode 100644 index 00000000000..c33efc10c79 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/id_meshupgradeprofile.go @@ -0,0 +1,139 @@ +package managedclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MeshUpgradeProfileId{}) +} + +var _ resourceids.ResourceId = &MeshUpgradeProfileId{} + +// MeshUpgradeProfileId is a struct representing the Resource ID for a Mesh Upgrade Profile +type MeshUpgradeProfileId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + MeshUpgradeProfileName string +} + +// NewMeshUpgradeProfileID returns a new MeshUpgradeProfileId struct +func NewMeshUpgradeProfileID(subscriptionId string, resourceGroupName string, managedClusterName string, meshUpgradeProfileName string) MeshUpgradeProfileId { + return MeshUpgradeProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + MeshUpgradeProfileName: meshUpgradeProfileName, + } +} + +// ParseMeshUpgradeProfileID parses 'input' into a MeshUpgradeProfileId +func ParseMeshUpgradeProfileID(input string) (*MeshUpgradeProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&MeshUpgradeProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MeshUpgradeProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMeshUpgradeProfileIDInsensitively parses 'input' case-insensitively into a MeshUpgradeProfileId +// note: this method should only be used for API response data and not user input +func ParseMeshUpgradeProfileIDInsensitively(input string) (*MeshUpgradeProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&MeshUpgradeProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MeshUpgradeProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MeshUpgradeProfileId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.MeshUpgradeProfileName, ok = input.Parsed["meshUpgradeProfileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "meshUpgradeProfileName", input) + } + + return nil +} + +// ValidateMeshUpgradeProfileID checks that 'input' can be parsed as a Mesh Upgrade Profile ID +func ValidateMeshUpgradeProfileID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseMeshUpgradeProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mesh Upgrade Profile ID +func (id MeshUpgradeProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/meshUpgradeProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.MeshUpgradeProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mesh Upgrade Profile ID +func (id MeshUpgradeProfileId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterName"), + resourceids.StaticSegment("staticMeshUpgradeProfiles", "meshUpgradeProfiles", "meshUpgradeProfiles"), + resourceids.UserSpecifiedSegment("meshUpgradeProfileName", "meshUpgradeProfileName"), + } +} + +// String returns a human-readable description of this Mesh Upgrade Profile ID +func (id MeshUpgradeProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Mesh Upgrade Profile Name: %q", id.MeshUpgradeProfileName), + } + return fmt.Sprintf("Mesh Upgrade Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/id_meshupgradeprofile_test.go b/resource-manager/containerservice/2025-02-01/managedclusters/id_meshupgradeprofile_test.go new file mode 100644 index 00000000000..eac2f86407e --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/id_meshupgradeprofile_test.go @@ -0,0 +1,327 @@ +package managedclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MeshUpgradeProfileId{} + +func TestNewMeshUpgradeProfileID(t *testing.T) { + id := NewMeshUpgradeProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "meshUpgradeProfileName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterName") + } + + if id.MeshUpgradeProfileName != "meshUpgradeProfileName" { + t.Fatalf("Expected %q but got %q for Segment 'MeshUpgradeProfileName'", id.MeshUpgradeProfileName, "meshUpgradeProfileName") + } +} + +func TestFormatMeshUpgradeProfileID(t *testing.T) { + actual := NewMeshUpgradeProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "meshUpgradeProfileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/meshUpgradeProfiles/meshUpgradeProfileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMeshUpgradeProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MeshUpgradeProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/meshUpgradeProfiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/meshUpgradeProfiles/meshUpgradeProfileName", + Expected: &MeshUpgradeProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + MeshUpgradeProfileName: "meshUpgradeProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/meshUpgradeProfiles/meshUpgradeProfileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMeshUpgradeProfileID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.MeshUpgradeProfileName != v.Expected.MeshUpgradeProfileName { + t.Fatalf("Expected %q but got %q for MeshUpgradeProfileName", v.Expected.MeshUpgradeProfileName, actual.MeshUpgradeProfileName) + } + + } +} + +func TestParseMeshUpgradeProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MeshUpgradeProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/meshUpgradeProfiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/mEsHuPgRaDePrOfIlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/meshUpgradeProfiles/meshUpgradeProfileName", + Expected: &MeshUpgradeProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + MeshUpgradeProfileName: "meshUpgradeProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/meshUpgradeProfiles/meshUpgradeProfileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/mEsHuPgRaDePrOfIlEs/mEsHuPgRaDePrOfIlEnAmE", + Expected: &MeshUpgradeProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRnAmE", + MeshUpgradeProfileName: "mEsHuPgRaDePrOfIlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/mEsHuPgRaDePrOfIlEs/mEsHuPgRaDePrOfIlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMeshUpgradeProfileIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.MeshUpgradeProfileName != v.Expected.MeshUpgradeProfileName { + t.Fatalf("Expected %q but got %q for MeshUpgradeProfileName", v.Expected.MeshUpgradeProfileName, actual.MeshUpgradeProfileName) + } + + } +} + +func TestSegmentsForMeshUpgradeProfileId(t *testing.T) { + segments := MeshUpgradeProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MeshUpgradeProfileId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_abortlatestoperation.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_abortlatestoperation.go new file mode 100644 index 00000000000..a37480f49c9 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_abortlatestoperation.go @@ -0,0 +1,71 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/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 AbortLatestOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AbortLatestOperation ... +func (c ManagedClustersClient) AbortLatestOperation(ctx context.Context, id commonids.KubernetesClusterId) (result AbortLatestOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/abort", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// AbortLatestOperationThenPoll performs AbortLatestOperation then polls until it's completed +func (c ManagedClustersClient) AbortLatestOperationThenPoll(ctx context.Context, id commonids.KubernetesClusterId) error { + result, err := c.AbortLatestOperation(ctx, id) + if err != nil { + return fmt.Errorf("performing AbortLatestOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AbortLatestOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_createorupdate.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_createorupdate.go new file mode 100644 index 00000000000..ee535475169 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_createorupdate.go @@ -0,0 +1,109 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/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 *ManagedCluster +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string + IfNoneMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + if o.IfNoneMatch != nil { + out.Append("If-None-Match", fmt.Sprintf("%v", *o.IfNoneMatch)) + } + 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 ManagedClustersClient) CreateOrUpdate(ctx context.Context, id commonids.KubernetesClusterId, input ManagedCluster, 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 ManagedClustersClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.KubernetesClusterId, input ManagedCluster, 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/containerservice/2025-02-01/managedclusters/method_delete.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_delete.go new file mode 100644 index 00000000000..e73ea43ac3f --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_delete.go @@ -0,0 +1,100 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/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 { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + 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 ManagedClustersClient) Delete(ctx context.Context, id commonids.KubernetesClusterId, 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 ManagedClustersClient) DeleteThenPoll(ctx context.Context, id commonids.KubernetesClusterId, 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/containerservice/2025-02-01/managedclusters/method_get.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_get.go new file mode 100644 index 00000000000..5c5b9cd89b8 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_get.go @@ -0,0 +1,54 @@ +package managedclusters + +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 *ManagedCluster +} + +// Get ... +func (c ManagedClustersClient) Get(ctx context.Context, id commonids.KubernetesClusterId) (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 ManagedCluster + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_getaccessprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_getaccessprofile.go new file mode 100644 index 00000000000..99bbda7cca5 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_getaccessprofile.go @@ -0,0 +1,54 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAccessProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedClusterAccessProfile +} + +// GetAccessProfile ... +func (c ManagedClustersClient) GetAccessProfile(ctx context.Context, id AccessProfileId) (result GetAccessProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listCredential", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedClusterAccessProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_getcommandresult.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_getcommandresult.go new file mode 100644 index 00000000000..9cd6f99a5f9 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_getcommandresult.go @@ -0,0 +1,54 @@ +package managedclusters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetCommandResultOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RunCommandResult +} + +// GetCommandResult ... +func (c ManagedClustersClient) GetCommandResult(ctx context.Context, id CommandResultId) (result GetCommandResultOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 RunCommandResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_getmeshrevisionprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_getmeshrevisionprofile.go new file mode 100644 index 00000000000..aba6637b834 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_getmeshrevisionprofile.go @@ -0,0 +1,53 @@ +package managedclusters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMeshRevisionProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MeshRevisionProfile +} + +// GetMeshRevisionProfile ... +func (c ManagedClustersClient) GetMeshRevisionProfile(ctx context.Context, id MeshRevisionProfileId) (result GetMeshRevisionProfileOperationResponse, 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 MeshRevisionProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_getmeshupgradeprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_getmeshupgradeprofile.go new file mode 100644 index 00000000000..536044f5875 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_getmeshupgradeprofile.go @@ -0,0 +1,53 @@ +package managedclusters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMeshUpgradeProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MeshUpgradeProfile +} + +// GetMeshUpgradeProfile ... +func (c ManagedClustersClient) GetMeshUpgradeProfile(ctx context.Context, id MeshUpgradeProfileId) (result GetMeshUpgradeProfileOperationResponse, 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 MeshUpgradeProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_getupgradeprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_getupgradeprofile.go new file mode 100644 index 00000000000..b5a5533d9e3 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_getupgradeprofile.go @@ -0,0 +1,55 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetUpgradeProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedClusterUpgradeProfile +} + +// GetUpgradeProfile ... +func (c ManagedClustersClient) GetUpgradeProfile(ctx context.Context, id commonids.KubernetesClusterId) (result GetUpgradeProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/upgradeProfiles/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 ManagedClusterUpgradeProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_list.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_list.go new file mode 100644 index 00000000000..026d6c9e193 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_list.go @@ -0,0 +1,106 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ManagedCluster +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedCluster +} + +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 ManagedClustersClient) 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.ContainerService/managedClusters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ManagedCluster `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 ManagedClustersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ManagedClusterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClustersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ManagedClusterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ManagedCluster, 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/containerservice/2025-02-01/managedclusters/method_listbyresourcegroup.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_listbyresourcegroup.go new file mode 100644 index 00000000000..3243b394520 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ManagedCluster +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedCluster +} + +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 ManagedClustersClient) 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.ContainerService/managedClusters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ManagedCluster `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 ManagedClustersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ManagedClusterOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClustersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ManagedClusterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ManagedCluster, 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/containerservice/2025-02-01/managedclusters/method_listclusteradmincredentials.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_listclusteradmincredentials.go new file mode 100644 index 00000000000..7ccb6f0d6eb --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_listclusteradmincredentials.go @@ -0,0 +1,84 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListClusterAdminCredentialsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CredentialResults +} + +type ListClusterAdminCredentialsOperationOptions struct { + ServerFqdn *string +} + +func DefaultListClusterAdminCredentialsOperationOptions() ListClusterAdminCredentialsOperationOptions { + return ListClusterAdminCredentialsOperationOptions{} +} + +func (o ListClusterAdminCredentialsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListClusterAdminCredentialsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListClusterAdminCredentialsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ServerFqdn != nil { + out.Append("server-fqdn", fmt.Sprintf("%v", *o.ServerFqdn)) + } + return &out +} + +// ListClusterAdminCredentials ... +func (c ManagedClustersClient) ListClusterAdminCredentials(ctx context.Context, id commonids.KubernetesClusterId, options ListClusterAdminCredentialsOperationOptions) (result ListClusterAdminCredentialsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/listClusterAdminCredential", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CredentialResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_listclustermonitoringusercredentials.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_listclustermonitoringusercredentials.go new file mode 100644 index 00000000000..cdf8383752e --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_listclustermonitoringusercredentials.go @@ -0,0 +1,84 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListClusterMonitoringUserCredentialsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CredentialResults +} + +type ListClusterMonitoringUserCredentialsOperationOptions struct { + ServerFqdn *string +} + +func DefaultListClusterMonitoringUserCredentialsOperationOptions() ListClusterMonitoringUserCredentialsOperationOptions { + return ListClusterMonitoringUserCredentialsOperationOptions{} +} + +func (o ListClusterMonitoringUserCredentialsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListClusterMonitoringUserCredentialsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListClusterMonitoringUserCredentialsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ServerFqdn != nil { + out.Append("server-fqdn", fmt.Sprintf("%v", *o.ServerFqdn)) + } + return &out +} + +// ListClusterMonitoringUserCredentials ... +func (c ManagedClustersClient) ListClusterMonitoringUserCredentials(ctx context.Context, id commonids.KubernetesClusterId, options ListClusterMonitoringUserCredentialsOperationOptions) (result ListClusterMonitoringUserCredentialsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/listClusterMonitoringUserCredential", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CredentialResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_listclusterusercredentials.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_listclusterusercredentials.go new file mode 100644 index 00000000000..ce168c171aa --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_listclusterusercredentials.go @@ -0,0 +1,88 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListClusterUserCredentialsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CredentialResults +} + +type ListClusterUserCredentialsOperationOptions struct { + Format *Format + ServerFqdn *string +} + +func DefaultListClusterUserCredentialsOperationOptions() ListClusterUserCredentialsOperationOptions { + return ListClusterUserCredentialsOperationOptions{} +} + +func (o ListClusterUserCredentialsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListClusterUserCredentialsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListClusterUserCredentialsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Format != nil { + out.Append("format", fmt.Sprintf("%v", *o.Format)) + } + if o.ServerFqdn != nil { + out.Append("server-fqdn", fmt.Sprintf("%v", *o.ServerFqdn)) + } + return &out +} + +// ListClusterUserCredentials ... +func (c ManagedClustersClient) ListClusterUserCredentials(ctx context.Context, id commonids.KubernetesClusterId, options ListClusterUserCredentialsOperationOptions) (result ListClusterUserCredentialsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/listClusterUserCredential", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CredentialResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_listkubernetesversions.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_listkubernetesversions.go new file mode 100644 index 00000000000..286125762cd --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_listkubernetesversions.go @@ -0,0 +1,54 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListKubernetesVersionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KubernetesVersionListResult +} + +// ListKubernetesVersions ... +func (c ManagedClustersClient) ListKubernetesVersions(ctx context.Context, id LocationId) (result ListKubernetesVersionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/kubernetesVersions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model KubernetesVersionListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_listmeshrevisionprofiles.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_listmeshrevisionprofiles.go new file mode 100644 index 00000000000..0172addb23c --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_listmeshrevisionprofiles.go @@ -0,0 +1,105 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListMeshRevisionProfilesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MeshRevisionProfile +} + +type ListMeshRevisionProfilesCompleteResult struct { + LatestHttpResponse *http.Response + Items []MeshRevisionProfile +} + +type ListMeshRevisionProfilesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListMeshRevisionProfilesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListMeshRevisionProfiles ... +func (c ManagedClustersClient) ListMeshRevisionProfiles(ctx context.Context, id LocationId) (result ListMeshRevisionProfilesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListMeshRevisionProfilesCustomPager{}, + Path: fmt.Sprintf("%s/meshRevisionProfiles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MeshRevisionProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMeshRevisionProfilesComplete retrieves all the results into a single object +func (c ManagedClustersClient) ListMeshRevisionProfilesComplete(ctx context.Context, id LocationId) (ListMeshRevisionProfilesCompleteResult, error) { + return c.ListMeshRevisionProfilesCompleteMatchingPredicate(ctx, id, MeshRevisionProfileOperationPredicate{}) +} + +// ListMeshRevisionProfilesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClustersClient) ListMeshRevisionProfilesCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate MeshRevisionProfileOperationPredicate) (result ListMeshRevisionProfilesCompleteResult, err error) { + items := make([]MeshRevisionProfile, 0) + + resp, err := c.ListMeshRevisionProfiles(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 = ListMeshRevisionProfilesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_listmeshupgradeprofiles.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_listmeshupgradeprofiles.go new file mode 100644 index 00000000000..b73c93f81a9 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_listmeshupgradeprofiles.go @@ -0,0 +1,106 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListMeshUpgradeProfilesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MeshUpgradeProfile +} + +type ListMeshUpgradeProfilesCompleteResult struct { + LatestHttpResponse *http.Response + Items []MeshUpgradeProfile +} + +type ListMeshUpgradeProfilesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListMeshUpgradeProfilesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListMeshUpgradeProfiles ... +func (c ManagedClustersClient) ListMeshUpgradeProfiles(ctx context.Context, id commonids.KubernetesClusterId) (result ListMeshUpgradeProfilesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListMeshUpgradeProfilesCustomPager{}, + Path: fmt.Sprintf("%s/meshUpgradeProfiles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MeshUpgradeProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMeshUpgradeProfilesComplete retrieves all the results into a single object +func (c ManagedClustersClient) ListMeshUpgradeProfilesComplete(ctx context.Context, id commonids.KubernetesClusterId) (ListMeshUpgradeProfilesCompleteResult, error) { + return c.ListMeshUpgradeProfilesCompleteMatchingPredicate(ctx, id, MeshUpgradeProfileOperationPredicate{}) +} + +// ListMeshUpgradeProfilesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClustersClient) ListMeshUpgradeProfilesCompleteMatchingPredicate(ctx context.Context, id commonids.KubernetesClusterId, predicate MeshUpgradeProfileOperationPredicate) (result ListMeshUpgradeProfilesCompleteResult, err error) { + items := make([]MeshUpgradeProfile, 0) + + resp, err := c.ListMeshUpgradeProfiles(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 = ListMeshUpgradeProfilesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_listoutboundnetworkdependenciesendpoints.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_listoutboundnetworkdependenciesendpoints.go new file mode 100644 index 00000000000..21283e57ea3 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_listoutboundnetworkdependenciesendpoints.go @@ -0,0 +1,106 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOutboundNetworkDependenciesEndpointsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OutboundEnvironmentEndpoint +} + +type ListOutboundNetworkDependenciesEndpointsCompleteResult struct { + LatestHttpResponse *http.Response + Items []OutboundEnvironmentEndpoint +} + +type ListOutboundNetworkDependenciesEndpointsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListOutboundNetworkDependenciesEndpointsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListOutboundNetworkDependenciesEndpoints ... +func (c ManagedClustersClient) ListOutboundNetworkDependenciesEndpoints(ctx context.Context, id commonids.KubernetesClusterId) (result ListOutboundNetworkDependenciesEndpointsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListOutboundNetworkDependenciesEndpointsCustomPager{}, + 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 +} + +// ListOutboundNetworkDependenciesEndpointsComplete retrieves all the results into a single object +func (c ManagedClustersClient) ListOutboundNetworkDependenciesEndpointsComplete(ctx context.Context, id commonids.KubernetesClusterId) (ListOutboundNetworkDependenciesEndpointsCompleteResult, error) { + return c.ListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, OutboundEnvironmentEndpointOperationPredicate{}) +} + +// ListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClustersClient) ListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id commonids.KubernetesClusterId, predicate OutboundEnvironmentEndpointOperationPredicate) (result ListOutboundNetworkDependenciesEndpointsCompleteResult, err error) { + items := make([]OutboundEnvironmentEndpoint, 0) + + resp, err := c.ListOutboundNetworkDependenciesEndpoints(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 = ListOutboundNetworkDependenciesEndpointsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_resetaadprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_resetaadprofile.go new file mode 100644 index 00000000000..abdbb59c018 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_resetaadprofile.go @@ -0,0 +1,75 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/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 ResetAADProfileOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ResetAADProfile ... +func (c ManagedClustersClient) ResetAADProfile(ctx context.Context, id commonids.KubernetesClusterId, input ManagedClusterAADProfile) (result ResetAADProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetAADProfile", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResetAADProfileThenPoll performs ResetAADProfile then polls until it's completed +func (c ManagedClustersClient) ResetAADProfileThenPoll(ctx context.Context, id commonids.KubernetesClusterId, input ManagedClusterAADProfile) error { + result, err := c.ResetAADProfile(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ResetAADProfile: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResetAADProfile: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_resetserviceprincipalprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_resetserviceprincipalprofile.go new file mode 100644 index 00000000000..54589acaf03 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_resetserviceprincipalprofile.go @@ -0,0 +1,75 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/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 ResetServicePrincipalProfileOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ResetServicePrincipalProfile ... +func (c ManagedClustersClient) ResetServicePrincipalProfile(ctx context.Context, id commonids.KubernetesClusterId, input ManagedClusterServicePrincipalProfile) (result ResetServicePrincipalProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetServicePrincipalProfile", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResetServicePrincipalProfileThenPoll performs ResetServicePrincipalProfile then polls until it's completed +func (c ManagedClustersClient) ResetServicePrincipalProfileThenPoll(ctx context.Context, id commonids.KubernetesClusterId, input ManagedClusterServicePrincipalProfile) error { + result, err := c.ResetServicePrincipalProfile(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ResetServicePrincipalProfile: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResetServicePrincipalProfile: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_rotateclustercertificates.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_rotateclustercertificates.go new file mode 100644 index 00000000000..3d04938f645 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_rotateclustercertificates.go @@ -0,0 +1,71 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/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 RotateClusterCertificatesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RotateClusterCertificates ... +func (c ManagedClustersClient) RotateClusterCertificates(ctx context.Context, id commonids.KubernetesClusterId) (result RotateClusterCertificatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/rotateClusterCertificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RotateClusterCertificatesThenPoll performs RotateClusterCertificates then polls until it's completed +func (c ManagedClustersClient) RotateClusterCertificatesThenPoll(ctx context.Context, id commonids.KubernetesClusterId) error { + result, err := c.RotateClusterCertificates(ctx, id) + if err != nil { + return fmt.Errorf("performing RotateClusterCertificates: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RotateClusterCertificates: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_rotateserviceaccountsigningkeys.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_rotateserviceaccountsigningkeys.go new file mode 100644 index 00000000000..b4cecc16d85 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_rotateserviceaccountsigningkeys.go @@ -0,0 +1,71 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/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 RotateServiceAccountSigningKeysOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RotateServiceAccountSigningKeys ... +func (c ManagedClustersClient) RotateServiceAccountSigningKeys(ctx context.Context, id commonids.KubernetesClusterId) (result RotateServiceAccountSigningKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/rotateServiceAccountSigningKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RotateServiceAccountSigningKeysThenPoll performs RotateServiceAccountSigningKeys then polls until it's completed +func (c ManagedClustersClient) RotateServiceAccountSigningKeysThenPoll(ctx context.Context, id commonids.KubernetesClusterId) error { + result, err := c.RotateServiceAccountSigningKeys(ctx, id) + if err != nil { + return fmt.Errorf("performing RotateServiceAccountSigningKeys: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RotateServiceAccountSigningKeys: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_runcommand.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_runcommand.go new file mode 100644 index 00000000000..b64b4ec1b20 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_runcommand.go @@ -0,0 +1,76 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/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 RunCommandOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RunCommandResult +} + +// RunCommand ... +func (c ManagedClustersClient) RunCommand(ctx context.Context, id commonids.KubernetesClusterId, input RunCommandRequest) (result RunCommandOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + 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 +} + +// RunCommandThenPoll performs RunCommand then polls until it's completed +func (c ManagedClustersClient) RunCommandThenPoll(ctx context.Context, id commonids.KubernetesClusterId, input RunCommandRequest) error { + result, err := c.RunCommand(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RunCommand: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RunCommand: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/method_start.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_start.go new file mode 100644 index 00000000000..ba4549e7615 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_start.go @@ -0,0 +1,71 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Start ... +func (c ManagedClustersClient) Start(ctx context.Context, id commonids.KubernetesClusterId) (result StartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 ManagedClustersClient) StartThenPoll(ctx context.Context, id commonids.KubernetesClusterId) 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/containerservice/2025-02-01/managedclusters/method_stop.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_stop.go new file mode 100644 index 00000000000..3bec609e3b4 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_stop.go @@ -0,0 +1,71 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Stop ... +func (c ManagedClustersClient) Stop(ctx context.Context, id commonids.KubernetesClusterId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 ManagedClustersClient) StopThenPoll(ctx context.Context, id commonids.KubernetesClusterId) 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/containerservice/2025-02-01/managedclusters/method_updatetags.go b/resource-manager/containerservice/2025-02-01/managedclusters/method_updatetags.go new file mode 100644 index 00000000000..ef3920b358e --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/method_updatetags.go @@ -0,0 +1,104 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/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 UpdateTagsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedCluster +} + +type UpdateTagsOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateTagsOperationOptions() UpdateTagsOperationOptions { + return UpdateTagsOperationOptions{} +} + +func (o UpdateTagsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateTagsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UpdateTagsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// UpdateTags ... +func (c ManagedClustersClient) UpdateTags(ctx context.Context, id commonids.KubernetesClusterId, input TagsObject, options UpdateTagsOperationOptions) (result UpdateTagsOperationResponse, 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateTagsThenPoll performs UpdateTags then polls until it's completed +func (c ManagedClustersClient) UpdateTagsThenPoll(ctx context.Context, id commonids.KubernetesClusterId, input TagsObject, options UpdateTagsOperationOptions) error { + result, err := c.UpdateTags(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing UpdateTags: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateTags: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_accessprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_accessprofile.go new file mode 100644 index 00000000000..c13b64ab25d --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_accessprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessProfile struct { + KubeConfig *string `json:"kubeConfig,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_advancednetworking.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_advancednetworking.go new file mode 100644 index 00000000000..48c6487fdee --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_advancednetworking.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdvancedNetworking struct { + Enabled *bool `json:"enabled,omitempty"` + Observability *AdvancedNetworkingObservability `json:"observability,omitempty"` + Security *AdvancedNetworkingSecurity `json:"security,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_advancednetworkingobservability.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_advancednetworkingobservability.go new file mode 100644 index 00000000000..a491cdc7a17 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_advancednetworkingobservability.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdvancedNetworkingObservability struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_advancednetworkingsecurity.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_advancednetworkingsecurity.go new file mode 100644 index 00000000000..9243f025d77 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_advancednetworkingsecurity.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdvancedNetworkingSecurity struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_agentpoolnetworkprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_agentpoolnetworkprofile.go new file mode 100644 index 00000000000..1a5b19f5db1 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_agentpoolnetworkprofile.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolNetworkProfile struct { + AllowedHostPorts *[]PortRange `json:"allowedHostPorts,omitempty"` + ApplicationSecurityGroups *[]string `json:"applicationSecurityGroups,omitempty"` + NodePublicIPTags *[]IPTag `json:"nodePublicIPTags,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_agentpoolsecurityprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_agentpoolsecurityprofile.go new file mode 100644 index 00000000000..d4e84920034 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_agentpoolsecurityprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolSecurityProfile struct { + EnableSecureBoot *bool `json:"enableSecureBoot,omitempty"` + EnableVTPM *bool `json:"enableVTPM,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_agentpoolupgradesettings.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_agentpoolupgradesettings.go new file mode 100644 index 00000000000..741d796f8a3 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_agentpoolupgradesettings.go @@ -0,0 +1,10 @@ +package managedclusters + +// 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 { + DrainTimeoutInMinutes *int64 `json:"drainTimeoutInMinutes,omitempty"` + MaxSurge *string `json:"maxSurge,omitempty"` + NodeSoakDurationInMinutes *int64 `json:"nodeSoakDurationInMinutes,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_agentpoolwindowsprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_agentpoolwindowsprofile.go new file mode 100644 index 00000000000..5558f04ed00 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_agentpoolwindowsprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolWindowsProfile struct { + DisableOutboundNat *bool `json:"disableOutboundNat,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_azurekeyvaultkms.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_azurekeyvaultkms.go new file mode 100644 index 00000000000..57c4e7848f3 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_azurekeyvaultkms.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureKeyVaultKms struct { + Enabled *bool `json:"enabled,omitempty"` + KeyId *string `json:"keyId,omitempty"` + KeyVaultNetworkAccess *KeyVaultNetworkAccessTypes `json:"keyVaultNetworkAccess,omitempty"` + KeyVaultResourceId *string `json:"keyVaultResourceId,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_clusterupgradesettings.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_clusterupgradesettings.go new file mode 100644 index 00000000000..1510493ca17 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_clusterupgradesettings.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterUpgradeSettings struct { + OverrideSettings *UpgradeOverrideSettings `json:"overrideSettings,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_commandresultproperties.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_commandresultproperties.go new file mode 100644 index 00000000000..745a87ae4ea --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_commandresultproperties.go @@ -0,0 +1,43 @@ +package managedclusters + +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 CommandResultProperties struct { + ExitCode *int64 `json:"exitCode,omitempty"` + FinishedAt *string `json:"finishedAt,omitempty"` + Logs *string `json:"logs,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Reason *string `json:"reason,omitempty"` + StartedAt *string `json:"startedAt,omitempty"` +} + +func (o *CommandResultProperties) GetFinishedAtAsTime() (*time.Time, error) { + if o.FinishedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FinishedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *CommandResultProperties) SetFinishedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FinishedAt = &formatted +} + +func (o *CommandResultProperties) GetStartedAtAsTime() (*time.Time, error) { + if o.StartedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *CommandResultProperties) SetStartedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartedAt = &formatted +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_compatibleversions.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_compatibleversions.go new file mode 100644 index 00000000000..585f8e04d7b --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_compatibleversions.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CompatibleVersions struct { + Name *string `json:"name,omitempty"` + Versions *[]string `json:"versions,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_containerservicelinuxprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_containerservicelinuxprofile.go new file mode 100644 index 00000000000..a3abf14adeb --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_containerservicelinuxprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerServiceLinuxProfile struct { + AdminUsername string `json:"adminUsername"` + Ssh ContainerServiceSshConfiguration `json:"ssh"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_containerservicenetworkprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_containerservicenetworkprofile.go new file mode 100644 index 00000000000..14fe9ec66f6 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_containerservicenetworkprofile.go @@ -0,0 +1,23 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerServiceNetworkProfile struct { + AdvancedNetworking *AdvancedNetworking `json:"advancedNetworking,omitempty"` + DnsServiceIP *string `json:"dnsServiceIP,omitempty"` + IPFamilies *[]IPFamily `json:"ipFamilies,omitempty"` + LoadBalancerProfile *ManagedClusterLoadBalancerProfile `json:"loadBalancerProfile,omitempty"` + LoadBalancerSku *LoadBalancerSku `json:"loadBalancerSku,omitempty"` + NatGatewayProfile *ManagedClusterNATGatewayProfile `json:"natGatewayProfile,omitempty"` + NetworkDataplane *NetworkDataplane `json:"networkDataplane,omitempty"` + NetworkMode *NetworkMode `json:"networkMode,omitempty"` + NetworkPlugin *NetworkPlugin `json:"networkPlugin,omitempty"` + NetworkPluginMode *NetworkPluginMode `json:"networkPluginMode,omitempty"` + NetworkPolicy *NetworkPolicy `json:"networkPolicy,omitempty"` + OutboundType *OutboundType `json:"outboundType,omitempty"` + PodCidr *string `json:"podCidr,omitempty"` + PodCidrs *[]string `json:"podCidrs,omitempty"` + ServiceCidr *string `json:"serviceCidr,omitempty"` + ServiceCidrs *[]string `json:"serviceCidrs,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_containerservicesshconfiguration.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_containerservicesshconfiguration.go new file mode 100644 index 00000000000..4bf259bd15d --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_containerservicesshconfiguration.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerServiceSshConfiguration struct { + PublicKeys []ContainerServiceSshPublicKey `json:"publicKeys"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_containerservicesshpublickey.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_containerservicesshpublickey.go new file mode 100644 index 00000000000..7796cdf6a90 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_containerservicesshpublickey.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerServiceSshPublicKey struct { + KeyData string `json:"keyData"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_creationdata.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_creationdata.go new file mode 100644 index 00000000000..f2f19907006 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_creationdata.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreationData struct { + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_credentialresult.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_credentialresult.go new file mode 100644 index 00000000000..7002f56084e --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_credentialresult.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CredentialResult struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_credentialresults.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_credentialresults.go new file mode 100644 index 00000000000..c572432888e --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_credentialresults.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CredentialResults struct { + Kubeconfigs *[]CredentialResult `json:"kubeconfigs,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_endpointdependency.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_endpointdependency.go new file mode 100644 index 00000000000..ae8639b529b --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_endpointdependency.go @@ -0,0 +1,9 @@ +package managedclusters + +// 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/containerservice/2025-02-01/managedclusters/model_endpointdetail.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_endpointdetail.go new file mode 100644 index 00000000000..de73a2e9168 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_endpointdetail.go @@ -0,0 +1,11 @@ +package managedclusters + +// 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 { + Description *string `json:"description,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *string `json:"protocol,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_gpuprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_gpuprofile.go new file mode 100644 index 00000000000..e0f15232e1c --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_gpuprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GPUProfile struct { + Driver *GPUDriver `json:"driver,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_iptag.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_iptag.go new file mode 100644 index 00000000000..0aefb50d15f --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_iptag.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_istiocertificateauthority.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_istiocertificateauthority.go new file mode 100644 index 00000000000..1580575b782 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_istiocertificateauthority.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IstioCertificateAuthority struct { + Plugin *IstioPluginCertificateAuthority `json:"plugin,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_istiocomponents.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_istiocomponents.go new file mode 100644 index 00000000000..6dff6ff1534 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_istiocomponents.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IstioComponents struct { + EgressGateways *[]IstioEgressGateway `json:"egressGateways,omitempty"` + IngressGateways *[]IstioIngressGateway `json:"ingressGateways,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_istioegressgateway.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_istioegressgateway.go new file mode 100644 index 00000000000..40497051c52 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_istioegressgateway.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IstioEgressGateway struct { + Enabled bool `json:"enabled"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_istioingressgateway.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_istioingressgateway.go new file mode 100644 index 00000000000..12832f48114 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_istioingressgateway.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IstioIngressGateway struct { + Enabled bool `json:"enabled"` + Mode IstioIngressGatewayMode `json:"mode"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_istioplugincertificateauthority.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_istioplugincertificateauthority.go new file mode 100644 index 00000000000..4ae2f736c6a --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_istioplugincertificateauthority.go @@ -0,0 +1,12 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IstioPluginCertificateAuthority struct { + CertChainObjectName *string `json:"certChainObjectName,omitempty"` + CertObjectName *string `json:"certObjectName,omitempty"` + KeyObjectName *string `json:"keyObjectName,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + RootCertObjectName *string `json:"rootCertObjectName,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_istioservicemesh.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_istioservicemesh.go new file mode 100644 index 00000000000..968c2f018dc --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_istioservicemesh.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IstioServiceMesh struct { + CertificateAuthority *IstioCertificateAuthority `json:"certificateAuthority,omitempty"` + Components *IstioComponents `json:"components,omitempty"` + Revisions *[]string `json:"revisions,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_kubeletconfig.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_kubeletconfig.go new file mode 100644 index 00000000000..0f4036b4e7c --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_kubeletconfig.go @@ -0,0 +1,18 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeletConfig struct { + AllowedUnsafeSysctls *[]string `json:"allowedUnsafeSysctls,omitempty"` + ContainerLogMaxFiles *int64 `json:"containerLogMaxFiles,omitempty"` + ContainerLogMaxSizeMB *int64 `json:"containerLogMaxSizeMB,omitempty"` + CpuCfsQuota *bool `json:"cpuCfsQuota,omitempty"` + CpuCfsQuotaPeriod *string `json:"cpuCfsQuotaPeriod,omitempty"` + CpuManagerPolicy *string `json:"cpuManagerPolicy,omitempty"` + FailSwapOn *bool `json:"failSwapOn,omitempty"` + ImageGcHighThreshold *int64 `json:"imageGcHighThreshold,omitempty"` + ImageGcLowThreshold *int64 `json:"imageGcLowThreshold,omitempty"` + PodMaxPids *int64 `json:"podMaxPids,omitempty"` + TopologyManagerPolicy *string `json:"topologyManagerPolicy,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_kubernetespatchversion.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_kubernetespatchversion.go new file mode 100644 index 00000000000..017737dac6a --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_kubernetespatchversion.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesPatchVersion struct { + Upgrades *[]string `json:"upgrades,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_kubernetesversion.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_kubernetesversion.go new file mode 100644 index 00000000000..d1ad17500d2 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_kubernetesversion.go @@ -0,0 +1,12 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesVersion struct { + Capabilities *KubernetesVersionCapabilities `json:"capabilities,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + PatchVersions *map[string]KubernetesPatchVersion `json:"patchVersions,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_kubernetesversioncapabilities.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_kubernetesversioncapabilities.go new file mode 100644 index 00000000000..b5729422404 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_kubernetesversioncapabilities.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesVersionCapabilities struct { + SupportPlan *[]KubernetesSupportPlan `json:"supportPlan,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_kubernetesversionlistresult.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_kubernetesversionlistresult.go new file mode 100644 index 00000000000..a8b1127a230 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_kubernetesversionlistresult.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesVersionListResult struct { + Values *[]KubernetesVersion `json:"values,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_linuxosconfig.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_linuxosconfig.go new file mode 100644 index 00000000000..431f6faa2aa --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_linuxosconfig.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinuxOSConfig struct { + SwapFileSizeMB *int64 `json:"swapFileSizeMB,omitempty"` + Sysctls *SysctlConfig `json:"sysctls,omitempty"` + TransparentHugePageDefrag *string `json:"transparentHugePageDefrag,omitempty"` + TransparentHugePageEnabled *string `json:"transparentHugePageEnabled,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedcluster.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedcluster.go new file mode 100644 index 00000000000..1eafd7b3285 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedcluster.go @@ -0,0 +1,24 @@ +package managedclusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "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 ManagedCluster struct { + ETag *string `json:"eTag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ManagedClusterProperties `json:"properties,omitempty"` + Sku *ManagedClusterSKU `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/containerservice/2025-02-01/managedclusters/model_managedclusteraadprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteraadprofile.go new file mode 100644 index 00000000000..271addb1fd4 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteraadprofile.go @@ -0,0 +1,14 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAADProfile struct { + AdminGroupObjectIDs *[]string `json:"adminGroupObjectIDs,omitempty"` + ClientAppID *string `json:"clientAppID,omitempty"` + EnableAzureRBAC *bool `json:"enableAzureRBAC,omitempty"` + Managed *bool `json:"managed,omitempty"` + ServerAppID *string `json:"serverAppID,omitempty"` + ServerAppSecret *string `json:"serverAppSecret,omitempty"` + TenantID *string `json:"tenantID,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteraccessprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteraccessprofile.go new file mode 100644 index 00000000000..e248b2a253b --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteraccessprofile.go @@ -0,0 +1,18 @@ +package managedclusters + +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 ManagedClusterAccessProfile struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AccessProfile `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/containerservice/2025-02-01/managedclusters/model_managedclusteraddonprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteraddonprofile.go new file mode 100644 index 00000000000..7dc1f865d9d --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteraddonprofile.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAddonProfile struct { + Config *map[string]string `json:"config,omitempty"` + Enabled bool `json:"enabled"` + Identity *UserAssignedIdentity `json:"identity,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteragentpoolprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteragentpoolprofile.go new file mode 100644 index 00000000000..e076ea454ef --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteragentpoolprofile.go @@ -0,0 +1,60 @@ +package managedclusters + +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 ManagedClusterAgentPoolProfile struct { + AvailabilityZones *zones.Schema `json:"availabilityZones,omitempty"` + CapacityReservationGroupID *string `json:"capacityReservationGroupID,omitempty"` + Count *int64 `json:"count,omitempty"` + CreationData *CreationData `json:"creationData,omitempty"` + CurrentOrchestratorVersion *string `json:"currentOrchestratorVersion,omitempty"` + ETag *string `json:"eTag,omitempty"` + EnableAutoScaling *bool `json:"enableAutoScaling,omitempty"` + EnableEncryptionAtHost *bool `json:"enableEncryptionAtHost,omitempty"` + EnableFIPS *bool `json:"enableFIPS,omitempty"` + EnableNodePublicIP *bool `json:"enableNodePublicIP,omitempty"` + EnableUltraSSD *bool `json:"enableUltraSSD,omitempty"` + GpuInstanceProfile *GPUInstanceProfile `json:"gpuInstanceProfile,omitempty"` + GpuProfile *GPUProfile `json:"gpuProfile,omitempty"` + HostGroupID *string `json:"hostGroupID,omitempty"` + KubeletConfig *KubeletConfig `json:"kubeletConfig,omitempty"` + KubeletDiskType *KubeletDiskType `json:"kubeletDiskType,omitempty"` + LinuxOSConfig *LinuxOSConfig `json:"linuxOSConfig,omitempty"` + MaxCount *int64 `json:"maxCount,omitempty"` + MaxPods *int64 `json:"maxPods,omitempty"` + MessageOfTheDay *string `json:"messageOfTheDay,omitempty"` + MinCount *int64 `json:"minCount,omitempty"` + Mode *AgentPoolMode `json:"mode,omitempty"` + Name string `json:"name"` + NetworkProfile *AgentPoolNetworkProfile `json:"networkProfile,omitempty"` + NodeImageVersion *string `json:"nodeImageVersion,omitempty"` + NodeLabels *map[string]string `json:"nodeLabels,omitempty"` + NodePublicIPPrefixID *string `json:"nodePublicIPPrefixID,omitempty"` + NodeTaints *[]string `json:"nodeTaints,omitempty"` + OrchestratorVersion *string `json:"orchestratorVersion,omitempty"` + OsDiskSizeGB *int64 `json:"osDiskSizeGB,omitempty"` + OsDiskType *OSDiskType `json:"osDiskType,omitempty"` + OsSKU *OSSKU `json:"osSKU,omitempty"` + OsType *OSType `json:"osType,omitempty"` + PodSubnetID *string `json:"podSubnetID,omitempty"` + PowerState *PowerState `json:"powerState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ProximityPlacementGroupID *string `json:"proximityPlacementGroupID,omitempty"` + ScaleDownMode *ScaleDownMode `json:"scaleDownMode,omitempty"` + ScaleSetEvictionPolicy *ScaleSetEvictionPolicy `json:"scaleSetEvictionPolicy,omitempty"` + ScaleSetPriority *ScaleSetPriority `json:"scaleSetPriority,omitempty"` + SecurityProfile *AgentPoolSecurityProfile `json:"securityProfile,omitempty"` + SpotMaxPrice *float64 `json:"spotMaxPrice,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *AgentPoolType `json:"type,omitempty"` + UpgradeSettings *AgentPoolUpgradeSettings `json:"upgradeSettings,omitempty"` + VMSize *string `json:"vmSize,omitempty"` + VnetSubnetID *string `json:"vnetSubnetID,omitempty"` + WindowsProfile *AgentPoolWindowsProfile `json:"windowsProfile,omitempty"` + WorkloadRuntime *WorkloadRuntime `json:"workloadRuntime,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterapiserveraccessprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterapiserveraccessprofile.go new file mode 100644 index 00000000000..30b24b4e52d --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterapiserveraccessprofile.go @@ -0,0 +1,12 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAPIServerAccessProfile struct { + AuthorizedIPRanges *[]string `json:"authorizedIPRanges,omitempty"` + DisableRunCommand *bool `json:"disableRunCommand,omitempty"` + EnablePrivateCluster *bool `json:"enablePrivateCluster,omitempty"` + EnablePrivateClusterPublicFQDN *bool `json:"enablePrivateClusterPublicFQDN,omitempty"` + PrivateDNSZone *string `json:"privateDNSZone,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterautoupgradeprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterautoupgradeprofile.go new file mode 100644 index 00000000000..e43a6df257f --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterautoupgradeprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAutoUpgradeProfile struct { + NodeOSUpgradeChannel *NodeOSUpgradeChannel `json:"nodeOSUpgradeChannel,omitempty"` + UpgradeChannel *UpgradeChannel `json:"upgradeChannel,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterazuremonitorprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterazuremonitorprofile.go new file mode 100644 index 00000000000..8a18140e45a --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterazuremonitorprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAzureMonitorProfile struct { + Metrics *ManagedClusterAzureMonitorProfileMetrics `json:"metrics,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterazuremonitorprofilekubestatemetrics.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterazuremonitorprofilekubestatemetrics.go new file mode 100644 index 00000000000..ef0fb9066e2 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterazuremonitorprofilekubestatemetrics.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAzureMonitorProfileKubeStateMetrics struct { + MetricAnnotationsAllowList *string `json:"metricAnnotationsAllowList,omitempty"` + MetricLabelsAllowlist *string `json:"metricLabelsAllowlist,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterazuremonitorprofilemetrics.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterazuremonitorprofilemetrics.go new file mode 100644 index 00000000000..5c173441517 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterazuremonitorprofilemetrics.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAzureMonitorProfileMetrics struct { + Enabled bool `json:"enabled"` + KubeStateMetrics *ManagedClusterAzureMonitorProfileKubeStateMetrics `json:"kubeStateMetrics,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterbootstrapprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterbootstrapprofile.go new file mode 100644 index 00000000000..5515399cb05 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterbootstrapprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterBootstrapProfile struct { + ArtifactSource *ArtifactSource `json:"artifactSource,omitempty"` + ContainerRegistryId *string `json:"containerRegistryId,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustercostanalysis.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustercostanalysis.go new file mode 100644 index 00000000000..a54a571fe4e --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustercostanalysis.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterCostAnalysis struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterhttpproxyconfig.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterhttpproxyconfig.go new file mode 100644 index 00000000000..33161aad969 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterhttpproxyconfig.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterHTTPProxyConfig struct { + HTTPProxy *string `json:"httpProxy,omitempty"` + HTTPSProxy *string `json:"httpsProxy,omitempty"` + NoProxy *[]string `json:"noProxy,omitempty"` + TrustedCa *string `json:"trustedCa,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteringressprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteringressprofile.go new file mode 100644 index 00000000000..ef54c8e8069 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteringressprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterIngressProfile struct { + WebAppRouting *ManagedClusterIngressProfileWebAppRouting `json:"webAppRouting,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteringressprofilenginx.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteringressprofilenginx.go new file mode 100644 index 00000000000..60f57dd6a49 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteringressprofilenginx.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterIngressProfileNginx struct { + DefaultIngressControllerType *NginxIngressControllerType `json:"defaultIngressControllerType,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteringressprofilewebapprouting.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteringressprofilewebapprouting.go new file mode 100644 index 00000000000..9849e8ecc14 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteringressprofilewebapprouting.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterIngressProfileWebAppRouting struct { + DnsZoneResourceIds *[]string `json:"dnsZoneResourceIds,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Identity *UserAssignedIdentity `json:"identity,omitempty"` + Nginx *ManagedClusterIngressProfileNginx `json:"nginx,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterloadbalancerprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterloadbalancerprofile.go new file mode 100644 index 00000000000..0d2207851bd --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterloadbalancerprofile.go @@ -0,0 +1,15 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterLoadBalancerProfile struct { + AllocatedOutboundPorts *int64 `json:"allocatedOutboundPorts,omitempty"` + BackendPoolType *BackendPoolType `json:"backendPoolType,omitempty"` + EffectiveOutboundIPs *[]ResourceReference `json:"effectiveOutboundIPs,omitempty"` + EnableMultipleStandardLoadBalancers *bool `json:"enableMultipleStandardLoadBalancers,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ManagedOutboundIPs *ManagedClusterLoadBalancerProfileManagedOutboundIPs `json:"managedOutboundIPs,omitempty"` + OutboundIPPrefixes *ManagedClusterLoadBalancerProfileOutboundIPPrefixes `json:"outboundIPPrefixes,omitempty"` + OutboundIPs *ManagedClusterLoadBalancerProfileOutboundIPs `json:"outboundIPs,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterloadbalancerprofilemanagedoutboundips.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterloadbalancerprofilemanagedoutboundips.go new file mode 100644 index 00000000000..b8d24680fed --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterloadbalancerprofilemanagedoutboundips.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterLoadBalancerProfileManagedOutboundIPs struct { + Count *int64 `json:"count,omitempty"` + CountIPv6 *int64 `json:"countIPv6,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterloadbalancerprofileoutboundipprefixes.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterloadbalancerprofileoutboundipprefixes.go new file mode 100644 index 00000000000..76893c76d85 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterloadbalancerprofileoutboundipprefixes.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterLoadBalancerProfileOutboundIPPrefixes struct { + PublicIPPrefixes *[]ResourceReference `json:"publicIPPrefixes,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterloadbalancerprofileoutboundips.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterloadbalancerprofileoutboundips.go new file mode 100644 index 00000000000..f0a60f5817e --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterloadbalancerprofileoutboundips.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterLoadBalancerProfileOutboundIPs struct { + PublicIPs *[]ResourceReference `json:"publicIPs,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustermanagedoutboundipprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustermanagedoutboundipprofile.go new file mode 100644 index 00000000000..ec079b6cdf4 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustermanagedoutboundipprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterManagedOutboundIPProfile struct { + Count *int64 `json:"count,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustermetricsprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustermetricsprofile.go new file mode 100644 index 00000000000..fd466216881 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustermetricsprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterMetricsProfile struct { + CostAnalysis *ManagedClusterCostAnalysis `json:"costAnalysis,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusternatgatewayprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusternatgatewayprofile.go new file mode 100644 index 00000000000..a7e37699c62 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusternatgatewayprofile.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterNATGatewayProfile struct { + EffectiveOutboundIPs *[]ResourceReference `json:"effectiveOutboundIPs,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ManagedOutboundIPProfile *ManagedClusterManagedOutboundIPProfile `json:"managedOutboundIPProfile,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusternoderesourcegroupprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusternoderesourcegroupprofile.go new file mode 100644 index 00000000000..1ae3147c267 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusternoderesourcegroupprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterNodeResourceGroupProfile struct { + RestrictionLevel *RestrictionLevel `json:"restrictionLevel,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteroidcissuerprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteroidcissuerprofile.go new file mode 100644 index 00000000000..b5d3be88f7d --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusteroidcissuerprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterOIDCIssuerProfile struct { + Enabled *bool `json:"enabled,omitempty"` + IssuerURL *string `json:"issuerURL,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentity.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentity.go new file mode 100644 index 00000000000..3bfb6799645 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentity.go @@ -0,0 +1,13 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPodIdentity struct { + BindingSelector *string `json:"bindingSelector,omitempty"` + Identity UserAssignedIdentity `json:"identity"` + Name string `json:"name"` + Namespace string `json:"namespace"` + ProvisioningInfo *ManagedClusterPodIdentityProvisioningInfo `json:"provisioningInfo,omitempty"` + ProvisioningState *ManagedClusterPodIdentityProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityexception.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityexception.go new file mode 100644 index 00000000000..28a710f9b5c --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityexception.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPodIdentityException struct { + Name string `json:"name"` + Namespace string `json:"namespace"` + PodLabels map[string]string `json:"podLabels"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityprofile.go new file mode 100644 index 00000000000..e32db30028a --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityprofile.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPodIdentityProfile struct { + AllowNetworkPluginKubenet *bool `json:"allowNetworkPluginKubenet,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + UserAssignedIdentities *[]ManagedClusterPodIdentity `json:"userAssignedIdentities,omitempty"` + UserAssignedIdentityExceptions *[]ManagedClusterPodIdentityException `json:"userAssignedIdentityExceptions,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityprovisioningerror.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityprovisioningerror.go new file mode 100644 index 00000000000..1fb66d9034f --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityprovisioningerror.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPodIdentityProvisioningError struct { + Error *ManagedClusterPodIdentityProvisioningErrorBody `json:"error,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityprovisioningerrorbody.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityprovisioningerrorbody.go new file mode 100644 index 00000000000..db4466f80bf --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityprovisioningerrorbody.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPodIdentityProvisioningErrorBody struct { + Code *string `json:"code,omitempty"` + Details *[]ManagedClusterPodIdentityProvisioningErrorBody `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityprovisioninginfo.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityprovisioninginfo.go new file mode 100644 index 00000000000..60464e39c82 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpodidentityprovisioninginfo.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPodIdentityProvisioningInfo struct { + Error *ManagedClusterPodIdentityProvisioningError `json:"error,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpoolupgradeprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpoolupgradeprofile.go new file mode 100644 index 00000000000..7bafa5df972 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpoolupgradeprofile.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPoolUpgradeProfile struct { + KubernetesVersion string `json:"kubernetesVersion"` + Name *string `json:"name,omitempty"` + OsType OSType `json:"osType"` + Upgrades *[]ManagedClusterPoolUpgradeProfileUpgradesInlined `json:"upgrades,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpoolupgradeprofileupgradesinlined.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpoolupgradeprofileupgradesinlined.go new file mode 100644 index 00000000000..ccc02dd9957 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpoolupgradeprofileupgradesinlined.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPoolUpgradeProfileUpgradesInlined struct { + IsPreview *bool `json:"isPreview,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterproperties.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterproperties.go new file mode 100644 index 00000000000..e5be9950798 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterproperties.go @@ -0,0 +1,50 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterProperties struct { + AadProfile *ManagedClusterAADProfile `json:"aadProfile,omitempty"` + AddonProfiles *map[string]ManagedClusterAddonProfile `json:"addonProfiles,omitempty"` + AgentPoolProfiles *[]ManagedClusterAgentPoolProfile `json:"agentPoolProfiles,omitempty"` + ApiServerAccessProfile *ManagedClusterAPIServerAccessProfile `json:"apiServerAccessProfile,omitempty"` + AutoScalerProfile *ManagedClusterPropertiesAutoScalerProfile `json:"autoScalerProfile,omitempty"` + AutoUpgradeProfile *ManagedClusterAutoUpgradeProfile `json:"autoUpgradeProfile,omitempty"` + AzureMonitorProfile *ManagedClusterAzureMonitorProfile `json:"azureMonitorProfile,omitempty"` + AzurePortalFQDN *string `json:"azurePortalFQDN,omitempty"` + BootstrapProfile *ManagedClusterBootstrapProfile `json:"bootstrapProfile,omitempty"` + CurrentKubernetesVersion *string `json:"currentKubernetesVersion,omitempty"` + DisableLocalAccounts *bool `json:"disableLocalAccounts,omitempty"` + DiskEncryptionSetID *string `json:"diskEncryptionSetID,omitempty"` + DnsPrefix *string `json:"dnsPrefix,omitempty"` + EnablePodSecurityPolicy *bool `json:"enablePodSecurityPolicy,omitempty"` + EnableRBAC *bool `json:"enableRBAC,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + FqdnSubdomain *string `json:"fqdnSubdomain,omitempty"` + HTTPProxyConfig *ManagedClusterHTTPProxyConfig `json:"httpProxyConfig,omitempty"` + IdentityProfile *map[string]UserAssignedIdentity `json:"identityProfile,omitempty"` + IngressProfile *ManagedClusterIngressProfile `json:"ingressProfile,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` + LinuxProfile *ContainerServiceLinuxProfile `json:"linuxProfile,omitempty"` + MaxAgentPools *int64 `json:"maxAgentPools,omitempty"` + MetricsProfile *ManagedClusterMetricsProfile `json:"metricsProfile,omitempty"` + NetworkProfile *ContainerServiceNetworkProfile `json:"networkProfile,omitempty"` + NodeResourceGroup *string `json:"nodeResourceGroup,omitempty"` + NodeResourceGroupProfile *ManagedClusterNodeResourceGroupProfile `json:"nodeResourceGroupProfile,omitempty"` + OidcIssuerProfile *ManagedClusterOIDCIssuerProfile `json:"oidcIssuerProfile,omitempty"` + PodIdentityProfile *ManagedClusterPodIdentityProfile `json:"podIdentityProfile,omitempty"` + PowerState *PowerState `json:"powerState,omitempty"` + PrivateFQDN *string `json:"privateFQDN,omitempty"` + PrivateLinkResources *[]PrivateLinkResource `json:"privateLinkResources,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + ResourceUID *string `json:"resourceUID,omitempty"` + SecurityProfile *ManagedClusterSecurityProfile `json:"securityProfile,omitempty"` + ServiceMeshProfile *ServiceMeshProfile `json:"serviceMeshProfile,omitempty"` + ServicePrincipalProfile *ManagedClusterServicePrincipalProfile `json:"servicePrincipalProfile,omitempty"` + StorageProfile *ManagedClusterStorageProfile `json:"storageProfile,omitempty"` + SupportPlan *KubernetesSupportPlan `json:"supportPlan,omitempty"` + UpgradeSettings *ClusterUpgradeSettings `json:"upgradeSettings,omitempty"` + WindowsProfile *ManagedClusterWindowsProfile `json:"windowsProfile,omitempty"` + WorkloadAutoScalerProfile *ManagedClusterWorkloadAutoScalerProfile `json:"workloadAutoScalerProfile,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpropertiesautoscalerprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpropertiesautoscalerprofile.go new file mode 100644 index 00000000000..3f718456e6e --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterpropertiesautoscalerprofile.go @@ -0,0 +1,27 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPropertiesAutoScalerProfile struct { + BalanceSimilarNodeGroups *string `json:"balance-similar-node-groups,omitempty"` + DaemonsetEvictionForEmptyNodes *bool `json:"daemonset-eviction-for-empty-nodes,omitempty"` + DaemonsetEvictionForOccupiedNodes *bool `json:"daemonset-eviction-for-occupied-nodes,omitempty"` + Expander *Expander `json:"expander,omitempty"` + IgnoreDaemonsetsUtilization *bool `json:"ignore-daemonsets-utilization,omitempty"` + MaxEmptyBulkDelete *string `json:"max-empty-bulk-delete,omitempty"` + MaxGracefulTerminationSec *string `json:"max-graceful-termination-sec,omitempty"` + MaxNodeProvisionTime *string `json:"max-node-provision-time,omitempty"` + MaxTotalUnreadyPercentage *string `json:"max-total-unready-percentage,omitempty"` + NewPodScaleUpDelay *string `json:"new-pod-scale-up-delay,omitempty"` + OkTotalUnreadyCount *string `json:"ok-total-unready-count,omitempty"` + ScaleDownDelayAfterAdd *string `json:"scale-down-delay-after-add,omitempty"` + ScaleDownDelayAfterDelete *string `json:"scale-down-delay-after-delete,omitempty"` + ScaleDownDelayAfterFailure *string `json:"scale-down-delay-after-failure,omitempty"` + ScaleDownUnneededTime *string `json:"scale-down-unneeded-time,omitempty"` + ScaleDownUnreadyTime *string `json:"scale-down-unready-time,omitempty"` + ScaleDownUtilizationThreshold *string `json:"scale-down-utilization-threshold,omitempty"` + ScanInterval *string `json:"scan-interval,omitempty"` + SkipNodesWithLocalStorage *string `json:"skip-nodes-with-local-storage,omitempty"` + SkipNodesWithSystemPods *string `json:"skip-nodes-with-system-pods,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofile.go new file mode 100644 index 00000000000..1c5892f9364 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofile.go @@ -0,0 +1,12 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSecurityProfile struct { + AzureKeyVaultKms *AzureKeyVaultKms `json:"azureKeyVaultKms,omitempty"` + CustomCATrustCertificates *[]string `json:"customCATrustCertificates,omitempty"` + Defender *ManagedClusterSecurityProfileDefender `json:"defender,omitempty"` + ImageCleaner *ManagedClusterSecurityProfileImageCleaner `json:"imageCleaner,omitempty"` + WorkloadIdentity *ManagedClusterSecurityProfileWorkloadIdentity `json:"workloadIdentity,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofiledefender.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofiledefender.go new file mode 100644 index 00000000000..c63debde097 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofiledefender.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSecurityProfileDefender struct { + LogAnalyticsWorkspaceResourceId *string `json:"logAnalyticsWorkspaceResourceId,omitempty"` + SecurityMonitoring *ManagedClusterSecurityProfileDefenderSecurityMonitoring `json:"securityMonitoring,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofiledefendersecuritymonitoring.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofiledefendersecuritymonitoring.go new file mode 100644 index 00000000000..de84c795fec --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofiledefendersecuritymonitoring.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSecurityProfileDefenderSecurityMonitoring struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofileimagecleaner.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofileimagecleaner.go new file mode 100644 index 00000000000..eb3e2ea7007 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofileimagecleaner.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSecurityProfileImageCleaner struct { + Enabled *bool `json:"enabled,omitempty"` + IntervalHours *int64 `json:"intervalHours,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofileworkloadidentity.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofileworkloadidentity.go new file mode 100644 index 00000000000..84f0312767b --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersecurityprofileworkloadidentity.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSecurityProfileWorkloadIdentity struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterserviceprincipalprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterserviceprincipalprofile.go new file mode 100644 index 00000000000..2a03beecdcc --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterserviceprincipalprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterServicePrincipalProfile struct { + ClientId string `json:"clientId"` + Secret *string `json:"secret,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersku.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersku.go new file mode 100644 index 00000000000..a4dcf9c50d3 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclustersku.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSKU struct { + Name *ManagedClusterSKUName `json:"name,omitempty"` + Tier *ManagedClusterSKUTier `json:"tier,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofile.go new file mode 100644 index 00000000000..11073ae103d --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofile.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterStorageProfile struct { + BlobCSIDriver *ManagedClusterStorageProfileBlobCSIDriver `json:"blobCSIDriver,omitempty"` + DiskCSIDriver *ManagedClusterStorageProfileDiskCSIDriver `json:"diskCSIDriver,omitempty"` + FileCSIDriver *ManagedClusterStorageProfileFileCSIDriver `json:"fileCSIDriver,omitempty"` + SnapshotController *ManagedClusterStorageProfileSnapshotController `json:"snapshotController,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofileblobcsidriver.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofileblobcsidriver.go new file mode 100644 index 00000000000..dc0e951be6b --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofileblobcsidriver.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterStorageProfileBlobCSIDriver struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofilediskcsidriver.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofilediskcsidriver.go new file mode 100644 index 00000000000..11eb0e5deb1 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofilediskcsidriver.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterStorageProfileDiskCSIDriver struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofilefilecsidriver.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofilefilecsidriver.go new file mode 100644 index 00000000000..986ece9d933 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofilefilecsidriver.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterStorageProfileFileCSIDriver struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofilesnapshotcontroller.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofilesnapshotcontroller.go new file mode 100644 index 00000000000..d46ee10b683 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterstorageprofilesnapshotcontroller.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterStorageProfileSnapshotController struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterupgradeprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterupgradeprofile.go new file mode 100644 index 00000000000..86274cdb14a --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterupgradeprofile.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterUpgradeProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ManagedClusterUpgradeProfileProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterupgradeprofileproperties.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterupgradeprofileproperties.go new file mode 100644 index 00000000000..4db4b126760 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterupgradeprofileproperties.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterUpgradeProfileProperties struct { + AgentPoolProfiles []ManagedClusterPoolUpgradeProfile `json:"agentPoolProfiles"` + ControlPlaneProfile ManagedClusterPoolUpgradeProfile `json:"controlPlaneProfile"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterwindowsprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterwindowsprofile.go new file mode 100644 index 00000000000..8e3cffdace8 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterwindowsprofile.go @@ -0,0 +1,12 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterWindowsProfile struct { + AdminPassword *string `json:"adminPassword,omitempty"` + AdminUsername string `json:"adminUsername"` + EnableCSIProxy *bool `json:"enableCSIProxy,omitempty"` + GmsaProfile *WindowsGmsaProfile `json:"gmsaProfile,omitempty"` + LicenseType *LicenseType `json:"licenseType,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterworkloadautoscalerprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterworkloadautoscalerprofile.go new file mode 100644 index 00000000000..891a44a0084 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterworkloadautoscalerprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterWorkloadAutoScalerProfile struct { + Keda *ManagedClusterWorkloadAutoScalerProfileKeda `json:"keda,omitempty"` + VerticalPodAutoscaler *ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler `json:"verticalPodAutoscaler,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterworkloadautoscalerprofilekeda.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterworkloadautoscalerprofilekeda.go new file mode 100644 index 00000000000..7115a06bfb3 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterworkloadautoscalerprofilekeda.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterWorkloadAutoScalerProfileKeda struct { + Enabled bool `json:"enabled"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterworkloadautoscalerprofileverticalpodautoscaler.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterworkloadautoscalerprofileverticalpodautoscaler.go new file mode 100644 index 00000000000..baf9e23d43c --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_managedclusterworkloadautoscalerprofileverticalpodautoscaler.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler struct { + Enabled bool `json:"enabled"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_meshrevision.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_meshrevision.go new file mode 100644 index 00000000000..e867a34a526 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_meshrevision.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MeshRevision struct { + CompatibleWith *[]CompatibleVersions `json:"compatibleWith,omitempty"` + Revision *string `json:"revision,omitempty"` + Upgrades *[]string `json:"upgrades,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_meshrevisionprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_meshrevisionprofile.go new file mode 100644 index 00000000000..40b56bf28d8 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_meshrevisionprofile.go @@ -0,0 +1,16 @@ +package managedclusters + +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 MeshRevisionProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MeshRevisionProfileProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_meshrevisionprofileproperties.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_meshrevisionprofileproperties.go new file mode 100644 index 00000000000..4d72f23dadb --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_meshrevisionprofileproperties.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MeshRevisionProfileProperties struct { + MeshRevisions *[]MeshRevision `json:"meshRevisions,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_meshupgradeprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_meshupgradeprofile.go new file mode 100644 index 00000000000..804e24cc19b --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_meshupgradeprofile.go @@ -0,0 +1,16 @@ +package managedclusters + +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 MeshUpgradeProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MeshRevision `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_outboundenvironmentendpoint.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_outboundenvironmentendpoint.go new file mode 100644 index 00000000000..a4f0d234bc8 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_outboundenvironmentendpoint.go @@ -0,0 +1,9 @@ +package managedclusters + +// 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/containerservice/2025-02-01/managedclusters/model_portrange.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_portrange.go new file mode 100644 index 00000000000..0a44c59e9c8 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_portrange.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PortRange struct { + PortEnd *int64 `json:"portEnd,omitempty"` + PortStart *int64 `json:"portStart,omitempty"` + Protocol *Protocol `json:"protocol,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_powerstate.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_powerstate.go new file mode 100644 index 00000000000..d5abeb15b66 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_powerstate.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PowerState struct { + Code *Code `json:"code,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_privatelinkresource.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_privatelinkresource.go new file mode 100644 index 00000000000..14d827574be --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_privatelinkresource.go @@ -0,0 +1,13 @@ +package managedclusters + +// 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 { + GroupId *string `json:"groupId,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + PrivateLinkServiceID *string `json:"privateLinkServiceID,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_resourcereference.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_resourcereference.go new file mode 100644 index 00000000000..dbb05bb4711 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_resourcereference.go @@ -0,0 +1,8 @@ +package managedclusters + +// 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/containerservice/2025-02-01/managedclusters/model_runcommandrequest.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_runcommandrequest.go new file mode 100644 index 00000000000..caa9ae3d0cd --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_runcommandrequest.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunCommandRequest struct { + ClusterToken *string `json:"clusterToken,omitempty"` + Command string `json:"command"` + Context *string `json:"context,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_runcommandresult.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_runcommandresult.go new file mode 100644 index 00000000000..59cfc374de3 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_runcommandresult.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunCommandResult struct { + Id *string `json:"id,omitempty"` + Properties *CommandResultProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_servicemeshprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_servicemeshprofile.go new file mode 100644 index 00000000000..781365d16f3 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_servicemeshprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceMeshProfile struct { + Istio *IstioServiceMesh `json:"istio,omitempty"` + Mode ServiceMeshMode `json:"mode"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_sysctlconfig.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_sysctlconfig.go new file mode 100644 index 00000000000..00f3cc50224 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_sysctlconfig.go @@ -0,0 +1,35 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SysctlConfig struct { + FsAioMaxNr *int64 `json:"fsAioMaxNr,omitempty"` + FsFileMax *int64 `json:"fsFileMax,omitempty"` + FsInotifyMaxUserWatches *int64 `json:"fsInotifyMaxUserWatches,omitempty"` + FsNrOpen *int64 `json:"fsNrOpen,omitempty"` + KernelThreadsMax *int64 `json:"kernelThreadsMax,omitempty"` + NetCoreNetdevMaxBacklog *int64 `json:"netCoreNetdevMaxBacklog,omitempty"` + NetCoreOptmemMax *int64 `json:"netCoreOptmemMax,omitempty"` + NetCoreRmemDefault *int64 `json:"netCoreRmemDefault,omitempty"` + NetCoreRmemMax *int64 `json:"netCoreRmemMax,omitempty"` + NetCoreSomaxconn *int64 `json:"netCoreSomaxconn,omitempty"` + NetCoreWmemDefault *int64 `json:"netCoreWmemDefault,omitempty"` + NetCoreWmemMax *int64 `json:"netCoreWmemMax,omitempty"` + NetIPv4IPLocalPortRange *string `json:"netIpv4IpLocalPortRange,omitempty"` + NetIPv4NeighDefaultGcThresh1 *int64 `json:"netIpv4NeighDefaultGcThresh1,omitempty"` + NetIPv4NeighDefaultGcThresh2 *int64 `json:"netIpv4NeighDefaultGcThresh2,omitempty"` + NetIPv4NeighDefaultGcThresh3 *int64 `json:"netIpv4NeighDefaultGcThresh3,omitempty"` + NetIPv4TcpFinTimeout *int64 `json:"netIpv4TcpFinTimeout,omitempty"` + NetIPv4TcpKeepaliveProbes *int64 `json:"netIpv4TcpKeepaliveProbes,omitempty"` + NetIPv4TcpKeepaliveTime *int64 `json:"netIpv4TcpKeepaliveTime,omitempty"` + NetIPv4TcpMaxSynBacklog *int64 `json:"netIpv4TcpMaxSynBacklog,omitempty"` + NetIPv4TcpMaxTwBuckets *int64 `json:"netIpv4TcpMaxTwBuckets,omitempty"` + NetIPv4TcpTwReuse *bool `json:"netIpv4TcpTwReuse,omitempty"` + NetIPv4TcpkeepaliveIntvl *int64 `json:"netIpv4TcpkeepaliveIntvl,omitempty"` + NetNetfilterNfConntrackBuckets *int64 `json:"netNetfilterNfConntrackBuckets,omitempty"` + NetNetfilterNfConntrackMax *int64 `json:"netNetfilterNfConntrackMax,omitempty"` + VMMaxMapCount *int64 `json:"vmMaxMapCount,omitempty"` + VMSwappiness *int64 `json:"vmSwappiness,omitempty"` + VMVfsCachePressure *int64 `json:"vmVfsCachePressure,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_tagsobject.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_tagsobject.go new file mode 100644 index 00000000000..69f1454e3b1 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_tagsobject.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_upgradeoverridesettings.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_upgradeoverridesettings.go new file mode 100644 index 00000000000..6be73348ea0 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_upgradeoverridesettings.go @@ -0,0 +1,27 @@ +package managedclusters + +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 UpgradeOverrideSettings struct { + ForceUpgrade *bool `json:"forceUpgrade,omitempty"` + Until *string `json:"until,omitempty"` +} + +func (o *UpgradeOverrideSettings) GetUntilAsTime() (*time.Time, error) { + if o.Until == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Until, "2006-01-02T15:04:05Z07:00") +} + +func (o *UpgradeOverrideSettings) SetUntilAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Until = &formatted +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_userassignedidentity.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_userassignedidentity.go new file mode 100644 index 00000000000..b1eecd7085a --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_userassignedidentity.go @@ -0,0 +1,10 @@ +package managedclusters + +// 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"` + ObjectId *string `json:"objectId,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/model_windowsgmsaprofile.go b/resource-manager/containerservice/2025-02-01/managedclusters/model_windowsgmsaprofile.go new file mode 100644 index 00000000000..742f96764d4 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/model_windowsgmsaprofile.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WindowsGmsaProfile struct { + DnsServer *string `json:"dnsServer,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + RootDomainName *string `json:"rootDomainName,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/predicates.go b/resource-manager/containerservice/2025-02-01/managedclusters/predicates.go new file mode 100644 index 00000000000..3af85d2e142 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/predicates.go @@ -0,0 +1,96 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ManagedClusterOperationPredicate) Matches(input ManagedCluster) 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 +} + +type MeshRevisionProfileOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p MeshRevisionProfileOperationPredicate) Matches(input MeshRevisionProfile) 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 MeshUpgradeProfileOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p MeshUpgradeProfileOperationPredicate) Matches(input MeshUpgradeProfile) 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 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 +} diff --git a/resource-manager/containerservice/2025-02-01/managedclusters/version.go b/resource-manager/containerservice/2025-02-01/managedclusters/version.go new file mode 100644 index 00000000000..4c4d4b6d54d --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/managedclusters/version.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/managedclusters/2025-02-01" +} diff --git a/resource-manager/containerservice/2025-02-01/privateendpointconnections/README.md b/resource-manager/containerservice/2025-02-01/privateendpointconnections/README.md new file mode 100644 index 00000000000..dbd0ef5f0c7 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/privateendpointconnections/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/privateendpointconnections` Documentation + +The `privateendpointconnections` SDK allows for interaction with Azure Resource Manager `containerservice` (API Version `2025-02-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/containerservice/2025-02-01/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", "managedClusterName", "privateEndpointConnectionName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Get` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "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.List` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +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: `PrivateEndpointConnectionsClient.Update` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "privateEndpointConnectionName") + +payload := privateendpointconnections.PrivateEndpointConnection{ + // ... +} + + +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/containerservice/2025-02-01/privateendpointconnections/client.go b/resource-manager/containerservice/2025-02-01/privateendpointconnections/client.go new file mode 100644 index 00000000000..50eaf09dcce --- /dev/null +++ b/resource-manager/containerservice/2025-02-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/containerservice/2025-02-01/privateendpointconnections/constants.go b/resource-manager/containerservice/2025-02-01/privateendpointconnections/constants.go new file mode 100644 index 00000000000..20cf74bcad4 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/privateendpointconnections/constants.go @@ -0,0 +1,107 @@ +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 ConnectionStatus string + +const ( + ConnectionStatusApproved ConnectionStatus = "Approved" + ConnectionStatusDisconnected ConnectionStatus = "Disconnected" + ConnectionStatusPending ConnectionStatus = "Pending" + ConnectionStatusRejected ConnectionStatus = "Rejected" +) + +func PossibleValuesForConnectionStatus() []string { + return []string{ + string(ConnectionStatusApproved), + string(ConnectionStatusDisconnected), + string(ConnectionStatusPending), + string(ConnectionStatusRejected), + } +} + +func (s *ConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionStatus(input string) (*ConnectionStatus, error) { + vals := map[string]ConnectionStatus{ + "approved": ConnectionStatusApproved, + "disconnected": ConnectionStatusDisconnected, + "pending": ConnectionStatusPending, + "rejected": ConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionStatus(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCanceled PrivateEndpointConnectionProvisioningState = "Canceled" + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCanceled), + 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{ + "canceled": PrivateEndpointConnectionProvisioningStateCanceled, + "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 +} diff --git a/resource-manager/containerservice/2025-02-01/privateendpointconnections/id_privateendpointconnection.go b/resource-manager/containerservice/2025-02-01/privateendpointconnections/id_privateendpointconnection.go new file mode 100644 index 00000000000..383123bb5dc --- /dev/null +++ b/resource-manager/containerservice/2025-02-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 + ManagedClusterName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, managedClusterName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", 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.ContainerService/managedClusters/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, 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("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterName"), + 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("Managed Cluster Name: %q", id.ManagedClusterName), + 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/containerservice/2025-02-01/privateendpointconnections/id_privateendpointconnection_test.go b/resource-manager/containerservice/2025-02-01/privateendpointconnections/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..f180a2cbb26 --- /dev/null +++ b/resource-manager/containerservice/2025-02-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", "managedClusterName", "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.ManagedClusterName != "managedClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterName") + } + + 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", "managedClusterName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/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.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/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.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + 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.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/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.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRnAmE", + 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.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/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.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + 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/containerservice/2025-02-01/privateendpointconnections/method_delete.go b/resource-manager/containerservice/2025-02-01/privateendpointconnections/method_delete.go new file mode 100644 index 00000000000..2b9a343bdf0 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/privateendpointconnections/method_delete.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 DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) 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/containerservice/2025-02-01/privateendpointconnections/method_get.go b/resource-manager/containerservice/2025-02-01/privateendpointconnections/method_get.go new file mode 100644 index 00000000000..351242746d4 --- /dev/null +++ b/resource-manager/containerservice/2025-02-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/containerservice/2025-02-01/privateendpointconnections/method_list.go b/resource-manager/containerservice/2025-02-01/privateendpointconnections/method_list.go new file mode 100644 index 00000000000..1ed7cfe4cf6 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/privateendpointconnections/method_list.go @@ -0,0 +1,55 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *PrivateEndpointConnectionListResult +} + +// List ... +func (c PrivateEndpointConnectionsClient) List(ctx context.Context, id commonids.KubernetesClusterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateEndpointConnectionListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/privateendpointconnections/method_update.go b/resource-manager/containerservice/2025-02-01/privateendpointconnections/method_update.go new file mode 100644 index 00000000000..12c2adf4c15 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/privateendpointconnections/method_update.go @@ -0,0 +1,58 @@ +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// Update ... +func (c PrivateEndpointConnectionsClient) Update(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result UpdateOperationResponse, 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 PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/privateendpointconnections/model_privateendpoint.go b/resource-manager/containerservice/2025-02-01/privateendpointconnections/model_privateendpoint.go new file mode 100644 index 00000000000..1bc8cf2a97c --- /dev/null +++ b/resource-manager/containerservice/2025-02-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/containerservice/2025-02-01/privateendpointconnections/model_privateendpointconnection.go b/resource-manager/containerservice/2025-02-01/privateendpointconnections/model_privateendpointconnection.go new file mode 100644 index 00000000000..fde7f4db0fc --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/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/containerservice/2025-02-01/privateendpointconnections/model_privateendpointconnectionlistresult.go b/resource-manager/containerservice/2025-02-01/privateendpointconnections/model_privateendpointconnectionlistresult.go new file mode 100644 index 00000000000..92a9ecb105a --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/privateendpointconnections/model_privateendpointconnectionlistresult.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 PrivateEndpointConnectionListResult struct { + Value *[]PrivateEndpointConnection `json:"value,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/privateendpointconnections/model_privateendpointconnectionproperties.go b/resource-manager/containerservice/2025-02-01/privateendpointconnections/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..549d255f069 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/privateendpointconnections/model_privateendpointconnectionproperties.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 PrivateEndpointConnectionProperties struct { + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go b/resource-manager/containerservice/2025-02-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..677cab99f90 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,9 @@ +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 { + Description *string `json:"description,omitempty"` + Status *ConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/privateendpointconnections/version.go b/resource-manager/containerservice/2025-02-01/privateendpointconnections/version.go new file mode 100644 index 00000000000..e5049d2481d --- /dev/null +++ b/resource-manager/containerservice/2025-02-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 = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privateendpointconnections/2025-02-01" +} diff --git a/resource-manager/containerservice/2025-02-01/privatelinkresources/README.md b/resource-manager/containerservice/2025-02-01/privatelinkresources/README.md new file mode 100644 index 00000000000..c45bf690623 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/privatelinkresources/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/privatelinkresources` Documentation + +The `privatelinkresources` SDK allows for interaction with Azure Resource Manager `containerservice` (API Version `2025-02-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/containerservice/2025-02-01/privatelinkresources" +``` + + +### Client Initialization + +```go +client := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateLinkResourcesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +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/containerservice/2025-02-01/privatelinkresources/client.go b/resource-manager/containerservice/2025-02-01/privatelinkresources/client.go new file mode 100644 index 00000000000..28c00b21f03 --- /dev/null +++ b/resource-manager/containerservice/2025-02-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/containerservice/2025-02-01/privatelinkresources/method_list.go b/resource-manager/containerservice/2025-02-01/privatelinkresources/method_list.go new file mode 100644 index 00000000000..905a02fa803 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/privatelinkresources/method_list.go @@ -0,0 +1,55 @@ +package privatelinkresources + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *PrivateLinkResourcesListResult +} + +// List ... +func (c PrivateLinkResourcesClient) List(ctx context.Context, id commonids.KubernetesClusterId) (result ListOperationResponse, 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 PrivateLinkResourcesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/privatelinkresources/model_privatelinkresource.go b/resource-manager/containerservice/2025-02-01/privatelinkresources/model_privatelinkresource.go new file mode 100644 index 00000000000..3490b3d4e87 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/privatelinkresources/model_privatelinkresource.go @@ -0,0 +1,13 @@ +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 { + GroupId *string `json:"groupId,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + PrivateLinkServiceID *string `json:"privateLinkServiceID,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/privatelinkresources/model_privatelinkresourceslistresult.go b/resource-manager/containerservice/2025-02-01/privatelinkresources/model_privatelinkresourceslistresult.go new file mode 100644 index 00000000000..52cfe88b6e2 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/privatelinkresources/model_privatelinkresourceslistresult.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 PrivateLinkResourcesListResult struct { + Value *[]PrivateLinkResource `json:"value,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/privatelinkresources/version.go b/resource-manager/containerservice/2025-02-01/privatelinkresources/version.go new file mode 100644 index 00000000000..ac83128c1b3 --- /dev/null +++ b/resource-manager/containerservice/2025-02-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 = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privatelinkresources/2025-02-01" +} diff --git a/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid/README.md b/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid/README.md new file mode 100644 index 00000000000..c926673030d --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid/README.md @@ -0,0 +1,42 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid` Documentation + +The `resolveprivatelinkserviceid` SDK allows for interaction with Azure Resource Manager `containerservice` (API Version `2025-02-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/containerservice/2025-02-01/resolveprivatelinkserviceid" +``` + + +### Client Initialization + +```go +client := resolveprivatelinkserviceid.NewResolvePrivateLinkServiceIdClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResolvePrivateLinkServiceIdClient.POST` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +payload := resolveprivatelinkserviceid.PrivateLinkResource{ + // ... +} + + +read, err := client.POST(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/containerservice/2025-02-01/resolveprivatelinkserviceid/client.go b/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid/client.go new file mode 100644 index 00000000000..5682fe91725 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid/client.go @@ -0,0 +1,26 @@ +package resolveprivatelinkserviceid + +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 ResolvePrivateLinkServiceIdClient struct { + Client *resourcemanager.Client +} + +func NewResolvePrivateLinkServiceIdClientWithBaseURI(sdkApi sdkEnv.Api) (*ResolvePrivateLinkServiceIdClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "resolveprivatelinkserviceid", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ResolvePrivateLinkServiceIdClient: %+v", err) + } + + return &ResolvePrivateLinkServiceIdClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid/method_post.go b/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid/method_post.go new file mode 100644 index 00000000000..de55fb54ccc --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid/method_post.go @@ -0,0 +1,59 @@ +package resolveprivatelinkserviceid + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type POSTOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResource +} + +// POST ... +func (c ResolvePrivateLinkServiceIdClient) POST(ctx context.Context, id commonids.KubernetesClusterId, input PrivateLinkResource) (result POSTOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resolvePrivateLinkServiceId", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *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/containerservice/2025-02-01/resolveprivatelinkserviceid/model_privatelinkresource.go b/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid/model_privatelinkresource.go new file mode 100644 index 00000000000..4ff07dba897 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid/model_privatelinkresource.go @@ -0,0 +1,13 @@ +package resolveprivatelinkserviceid + +// 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 { + GroupId *string `json:"groupId,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + PrivateLinkServiceID *string `json:"privateLinkServiceID,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid/version.go b/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid/version.go new file mode 100644 index 00000000000..e8fca5313f5 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/resolveprivatelinkserviceid/version.go @@ -0,0 +1,10 @@ +package resolveprivatelinkserviceid + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/resolveprivatelinkserviceid/2025-02-01" +} diff --git a/resource-manager/containerservice/2025-02-01/snapshots/README.md b/resource-manager/containerservice/2025-02-01/snapshots/README.md new file mode 100644 index 00000000000..b02595c756a --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/snapshots/README.md @@ -0,0 +1,129 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/snapshots` Documentation + +The `snapshots` SDK allows for interaction with Azure Resource Manager `containerservice` (API Version `2025-02-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/containerservice/2025-02-01/snapshots" +``` + + +### Client Initialization + +```go +client := snapshots.NewSnapshotsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SnapshotsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := snapshots.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "snapshotName") + +payload := snapshots.Snapshot{ + // ... +} + + +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: `SnapshotsClient.Delete` + +```go +ctx := context.TODO() +id := snapshots.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "snapshotName") + +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: `SnapshotsClient.Get` + +```go +ctx := context.TODO() +id := snapshots.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "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 := 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: `SnapshotsClient.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: `SnapshotsClient.UpdateTags` + +```go +ctx := context.TODO() +id := snapshots.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "snapshotName") + +payload := snapshots.TagsObject{ + // ... +} + + +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/containerservice/2025-02-01/snapshots/client.go b/resource-manager/containerservice/2025-02-01/snapshots/client.go new file mode 100644 index 00000000000..678a64470aa --- /dev/null +++ b/resource-manager/containerservice/2025-02-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/containerservice/2025-02-01/snapshots/constants.go b/resource-manager/containerservice/2025-02-01/snapshots/constants.go new file mode 100644 index 00000000000..f8683c860fd --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/snapshots/constants.go @@ -0,0 +1,139 @@ +package snapshots + +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 OSSKU string + +const ( + OSSKUAzureLinux OSSKU = "AzureLinux" + OSSKUCBLMariner OSSKU = "CBLMariner" + OSSKUUbuntu OSSKU = "Ubuntu" + OSSKUWindowsTwoZeroOneNine OSSKU = "Windows2019" + OSSKUWindowsTwoZeroTwoTwo OSSKU = "Windows2022" +) + +func PossibleValuesForOSSKU() []string { + return []string{ + string(OSSKUAzureLinux), + string(OSSKUCBLMariner), + string(OSSKUUbuntu), + string(OSSKUWindowsTwoZeroOneNine), + string(OSSKUWindowsTwoZeroTwoTwo), + } +} + +func (s *OSSKU) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSSKU(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSSKU(input string) (*OSSKU, error) { + vals := map[string]OSSKU{ + "azurelinux": OSSKUAzureLinux, + "cblmariner": OSSKUCBLMariner, + "ubuntu": OSSKUUbuntu, + "windows2019": OSSKUWindowsTwoZeroOneNine, + "windows2022": OSSKUWindowsTwoZeroTwoTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSSKU(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 SnapshotType string + +const ( + SnapshotTypeNodePool SnapshotType = "NodePool" +) + +func PossibleValuesForSnapshotType() []string { + return []string{ + string(SnapshotTypeNodePool), + } +} + +func (s *SnapshotType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSnapshotType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSnapshotType(input string) (*SnapshotType, error) { + vals := map[string]SnapshotType{ + "nodepool": SnapshotTypeNodePool, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SnapshotType(input) + return &out, nil +} diff --git a/resource-manager/containerservice/2025-02-01/snapshots/id_snapshot.go b/resource-manager/containerservice/2025-02-01/snapshots/id_snapshot.go new file mode 100644 index 00000000000..8081e44fc0b --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/snapshots/id_snapshot.go @@ -0,0 +1,130 @@ +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 + SnapshotName string +} + +// NewSnapshotID returns a new SnapshotId struct +func NewSnapshotID(subscriptionId string, resourceGroupName string, snapshotName string) SnapshotId { + return SnapshotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + 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.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.ContainerService/snapshots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, 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("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + 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("Snapshot Name: %q", id.SnapshotName), + } + return fmt.Sprintf("Snapshot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2025-02-01/snapshots/id_snapshot_test.go b/resource-manager/containerservice/2025-02-01/snapshots/id_snapshot_test.go new file mode 100644 index 00000000000..67f5a402cf0 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/snapshots/id_snapshot_test.go @@ -0,0 +1,282 @@ +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", "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.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", "snapshotName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/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.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/snapshots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/snapshots/snapshotName", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SnapshotName: "snapshotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/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.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.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/snapshots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/sNaPsHoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/snapshots/snapshotName", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SnapshotName: "snapshotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/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.cOnTaInErSeRvIcE/sNaPsHoTs/sNaPsHoTnAmE", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + 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.cOnTaInErSeRvIcE/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.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/containerservice/2025-02-01/snapshots/method_createorupdate.go b/resource-manager/containerservice/2025-02-01/snapshots/method_createorupdate.go new file mode 100644 index 00000000000..2085af2f95b --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/snapshots/method_createorupdate.go @@ -0,0 +1,58 @@ +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Snapshot +} + +// CreateOrUpdate ... +func (c SnapshotsClient) CreateOrUpdate(ctx context.Context, id SnapshotId, input Snapshot) (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 Snapshot + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/snapshots/method_delete.go b/resource-manager/containerservice/2025-02-01/snapshots/method_delete.go new file mode 100644 index 00000000000..575cb8a6929 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/snapshots/method_delete.go @@ -0,0 +1,47 @@ +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 DeleteOperationResponse struct { + 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.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/containerservice/2025-02-01/snapshots/method_get.go b/resource-manager/containerservice/2025-02-01/snapshots/method_get.go new file mode 100644 index 00000000000..68b676f0115 --- /dev/null +++ b/resource-manager/containerservice/2025-02-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/containerservice/2025-02-01/snapshots/method_list.go b/resource-manager/containerservice/2025-02-01/snapshots/method_list.go new file mode 100644 index 00000000000..340f60c09b1 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/snapshots/method_list.go @@ -0,0 +1,106 @@ +package snapshots + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]Snapshot +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +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 SnapshotsClient) 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.ContainerService/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 +} + +// ListComplete retrieves all the results into a single object +func (c SnapshotsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SnapshotsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SnapshotOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Snapshot, 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/containerservice/2025-02-01/snapshots/method_listbyresourcegroup.go b/resource-manager/containerservice/2025-02-01/snapshots/method_listbyresourcegroup.go new file mode 100644 index 00000000000..fb276c706e9 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/snapshots/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package snapshots + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]Snapshot +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +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 SnapshotsClient) 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.ContainerService/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 +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c SnapshotsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SnapshotsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate SnapshotOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Snapshot, 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/containerservice/2025-02-01/snapshots/method_updatetags.go b/resource-manager/containerservice/2025-02-01/snapshots/method_updatetags.go new file mode 100644 index 00000000000..86fd5d87f00 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/snapshots/method_updatetags.go @@ -0,0 +1,57 @@ +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 UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Snapshot +} + +// UpdateTags ... +func (c SnapshotsClient) UpdateTags(ctx context.Context, id SnapshotId, input TagsObject) (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 Snapshot + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/snapshots/model_creationdata.go b/resource-manager/containerservice/2025-02-01/snapshots/model_creationdata.go new file mode 100644 index 00000000000..132e3459c82 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/snapshots/model_creationdata.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 CreationData struct { + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/snapshots/model_snapshot.go b/resource-manager/containerservice/2025-02-01/snapshots/model_snapshot.go new file mode 100644 index 00000000000..b2feb4ccdae --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/snapshots/model_snapshot.go @@ -0,0 +1,18 @@ +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"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/snapshots/model_snapshotproperties.go b/resource-manager/containerservice/2025-02-01/snapshots/model_snapshotproperties.go new file mode 100644 index 00000000000..962aa32598f --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/snapshots/model_snapshotproperties.go @@ -0,0 +1,15 @@ +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 SnapshotProperties struct { + CreationData *CreationData `json:"creationData,omitempty"` + EnableFIPS *bool `json:"enableFIPS,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` + NodeImageVersion *string `json:"nodeImageVersion,omitempty"` + OsSku *OSSKU `json:"osSku,omitempty"` + OsType *OSType `json:"osType,omitempty"` + SnapshotType *SnapshotType `json:"snapshotType,omitempty"` + VMSize *string `json:"vmSize,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/snapshots/model_tagsobject.go b/resource-manager/containerservice/2025-02-01/snapshots/model_tagsobject.go new file mode 100644 index 00000000000..30f646c1c9f --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/snapshots/model_tagsobject.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 TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/snapshots/predicates.go b/resource-manager/containerservice/2025-02-01/snapshots/predicates.go new file mode 100644 index 00000000000..832503e3b26 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/snapshots/predicates.go @@ -0,0 +1,32 @@ +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 SnapshotOperationPredicate struct { + Id *string + Location *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.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/containerservice/2025-02-01/snapshots/version.go b/resource-manager/containerservice/2025-02-01/snapshots/version.go new file mode 100644 index 00000000000..54494dd628a --- /dev/null +++ b/resource-manager/containerservice/2025-02-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 = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/snapshots/2025-02-01" +} diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/README.md b/resource-manager/containerservice/2025-02-01/trustedaccess/README.md new file mode 100644 index 00000000000..e1f76257a94 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/README.md @@ -0,0 +1,100 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2025-02-01/trustedaccess` Documentation + +The `trustedaccess` SDK allows for interaction with Azure Resource Manager `containerservice` (API Version `2025-02-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/containerservice/2025-02-01/trustedaccess" +``` + + +### Client Initialization + +```go +client := trustedaccess.NewTrustedAccessClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `TrustedAccessClient.RoleBindingsCreateOrUpdate` + +```go +ctx := context.TODO() +id := trustedaccess.NewTrustedAccessRoleBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "trustedAccessRoleBindingName") + +payload := trustedaccess.TrustedAccessRoleBinding{ + // ... +} + + +if err := client.RoleBindingsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `TrustedAccessClient.RoleBindingsDelete` + +```go +ctx := context.TODO() +id := trustedaccess.NewTrustedAccessRoleBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "trustedAccessRoleBindingName") + +if err := client.RoleBindingsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `TrustedAccessClient.RoleBindingsGet` + +```go +ctx := context.TODO() +id := trustedaccess.NewTrustedAccessRoleBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "trustedAccessRoleBindingName") + +read, err := client.RoleBindingsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TrustedAccessClient.RoleBindingsList` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName") + +// alternatively `client.RoleBindingsList(ctx, id)` can be used to do batched pagination +items, err := client.RoleBindingsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `TrustedAccessClient.RolesList` + +```go +ctx := context.TODO() +id := trustedaccess.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.RolesList(ctx, id)` can be used to do batched pagination +items, err := client.RolesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/client.go b/resource-manager/containerservice/2025-02-01/trustedaccess/client.go new file mode 100644 index 00000000000..e3e1d5a54e4 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/client.go @@ -0,0 +1,26 @@ +package trustedaccess + +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 TrustedAccessClient struct { + Client *resourcemanager.Client +} + +func NewTrustedAccessClientWithBaseURI(sdkApi sdkEnv.Api) (*TrustedAccessClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "trustedaccess", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TrustedAccessClient: %+v", err) + } + + return &TrustedAccessClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/constants.go b/resource-manager/containerservice/2025-02-01/trustedaccess/constants.go new file mode 100644 index 00000000000..8ab993f971c --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/constants.go @@ -0,0 +1,60 @@ +package trustedaccess + +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 TrustedAccessRoleBindingProvisioningState string + +const ( + TrustedAccessRoleBindingProvisioningStateCanceled TrustedAccessRoleBindingProvisioningState = "Canceled" + TrustedAccessRoleBindingProvisioningStateDeleting TrustedAccessRoleBindingProvisioningState = "Deleting" + TrustedAccessRoleBindingProvisioningStateFailed TrustedAccessRoleBindingProvisioningState = "Failed" + TrustedAccessRoleBindingProvisioningStateSucceeded TrustedAccessRoleBindingProvisioningState = "Succeeded" + TrustedAccessRoleBindingProvisioningStateUpdating TrustedAccessRoleBindingProvisioningState = "Updating" +) + +func PossibleValuesForTrustedAccessRoleBindingProvisioningState() []string { + return []string{ + string(TrustedAccessRoleBindingProvisioningStateCanceled), + string(TrustedAccessRoleBindingProvisioningStateDeleting), + string(TrustedAccessRoleBindingProvisioningStateFailed), + string(TrustedAccessRoleBindingProvisioningStateSucceeded), + string(TrustedAccessRoleBindingProvisioningStateUpdating), + } +} + +func (s *TrustedAccessRoleBindingProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTrustedAccessRoleBindingProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTrustedAccessRoleBindingProvisioningState(input string) (*TrustedAccessRoleBindingProvisioningState, error) { + vals := map[string]TrustedAccessRoleBindingProvisioningState{ + "canceled": TrustedAccessRoleBindingProvisioningStateCanceled, + "deleting": TrustedAccessRoleBindingProvisioningStateDeleting, + "failed": TrustedAccessRoleBindingProvisioningStateFailed, + "succeeded": TrustedAccessRoleBindingProvisioningStateSucceeded, + "updating": TrustedAccessRoleBindingProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TrustedAccessRoleBindingProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/id_location.go b/resource-manager/containerservice/2025-02-01/trustedaccess/id_location.go new file mode 100644 index 00000000000..9372d26414b --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/id_location.go @@ -0,0 +1,121 @@ +package trustedaccess + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) 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.ContainerService/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("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + 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/containerservice/2025-02-01/trustedaccess/id_location_test.go b/resource-manager/containerservice/2025-02-01/trustedaccess/id_location_test.go new file mode 100644 index 00000000000..d75d02aa0b9 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/id_location_test.go @@ -0,0 +1,237 @@ +package trustedaccess + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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.ContainerService/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.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/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.ContainerService/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.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/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.ContainerService/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/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.cOnTaInErSeRvIcE/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/containerservice/2025-02-01/trustedaccess/id_trustedaccessrolebinding.go b/resource-manager/containerservice/2025-02-01/trustedaccess/id_trustedaccessrolebinding.go new file mode 100644 index 00000000000..e53842f1ccd --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/id_trustedaccessrolebinding.go @@ -0,0 +1,139 @@ +package trustedaccess + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TrustedAccessRoleBindingId{}) +} + +var _ resourceids.ResourceId = &TrustedAccessRoleBindingId{} + +// TrustedAccessRoleBindingId is a struct representing the Resource ID for a Trusted Access Role Binding +type TrustedAccessRoleBindingId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + TrustedAccessRoleBindingName string +} + +// NewTrustedAccessRoleBindingID returns a new TrustedAccessRoleBindingId struct +func NewTrustedAccessRoleBindingID(subscriptionId string, resourceGroupName string, managedClusterName string, trustedAccessRoleBindingName string) TrustedAccessRoleBindingId { + return TrustedAccessRoleBindingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + TrustedAccessRoleBindingName: trustedAccessRoleBindingName, + } +} + +// ParseTrustedAccessRoleBindingID parses 'input' into a TrustedAccessRoleBindingId +func ParseTrustedAccessRoleBindingID(input string) (*TrustedAccessRoleBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&TrustedAccessRoleBindingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TrustedAccessRoleBindingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTrustedAccessRoleBindingIDInsensitively parses 'input' case-insensitively into a TrustedAccessRoleBindingId +// note: this method should only be used for API response data and not user input +func ParseTrustedAccessRoleBindingIDInsensitively(input string) (*TrustedAccessRoleBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&TrustedAccessRoleBindingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TrustedAccessRoleBindingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TrustedAccessRoleBindingId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.TrustedAccessRoleBindingName, ok = input.Parsed["trustedAccessRoleBindingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "trustedAccessRoleBindingName", input) + } + + return nil +} + +// ValidateTrustedAccessRoleBindingID checks that 'input' can be parsed as a Trusted Access Role Binding ID +func ValidateTrustedAccessRoleBindingID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseTrustedAccessRoleBindingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Trusted Access Role Binding ID +func (id TrustedAccessRoleBindingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/trustedAccessRoleBindings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.TrustedAccessRoleBindingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Trusted Access Role Binding ID +func (id TrustedAccessRoleBindingId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterName"), + resourceids.StaticSegment("staticTrustedAccessRoleBindings", "trustedAccessRoleBindings", "trustedAccessRoleBindings"), + resourceids.UserSpecifiedSegment("trustedAccessRoleBindingName", "trustedAccessRoleBindingName"), + } +} + +// String returns a human-readable description of this Trusted Access Role Binding ID +func (id TrustedAccessRoleBindingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Trusted Access Role Binding Name: %q", id.TrustedAccessRoleBindingName), + } + return fmt.Sprintf("Trusted Access Role Binding (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/id_trustedaccessrolebinding_test.go b/resource-manager/containerservice/2025-02-01/trustedaccess/id_trustedaccessrolebinding_test.go new file mode 100644 index 00000000000..bea546caaef --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/id_trustedaccessrolebinding_test.go @@ -0,0 +1,327 @@ +package trustedaccess + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &TrustedAccessRoleBindingId{} + +func TestNewTrustedAccessRoleBindingID(t *testing.T) { + id := NewTrustedAccessRoleBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "trustedAccessRoleBindingName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterName") + } + + if id.TrustedAccessRoleBindingName != "trustedAccessRoleBindingName" { + t.Fatalf("Expected %q but got %q for Segment 'TrustedAccessRoleBindingName'", id.TrustedAccessRoleBindingName, "trustedAccessRoleBindingName") + } +} + +func TestFormatTrustedAccessRoleBindingID(t *testing.T) { + actual := NewTrustedAccessRoleBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterName", "trustedAccessRoleBindingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/trustedAccessRoleBindings/trustedAccessRoleBindingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTrustedAccessRoleBindingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TrustedAccessRoleBindingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/trustedAccessRoleBindings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/trustedAccessRoleBindings/trustedAccessRoleBindingName", + Expected: &TrustedAccessRoleBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + TrustedAccessRoleBindingName: "trustedAccessRoleBindingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/trustedAccessRoleBindings/trustedAccessRoleBindingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTrustedAccessRoleBindingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.TrustedAccessRoleBindingName != v.Expected.TrustedAccessRoleBindingName { + t.Fatalf("Expected %q but got %q for TrustedAccessRoleBindingName", v.Expected.TrustedAccessRoleBindingName, actual.TrustedAccessRoleBindingName) + } + + } +} + +func TestParseTrustedAccessRoleBindingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TrustedAccessRoleBindingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/trustedAccessRoleBindings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/tRuStEdAcCeSsRoLeBiNdInGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/trustedAccessRoleBindings/trustedAccessRoleBindingName", + Expected: &TrustedAccessRoleBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterName", + TrustedAccessRoleBindingName: "trustedAccessRoleBindingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterName/trustedAccessRoleBindings/trustedAccessRoleBindingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/tRuStEdAcCeSsRoLeBiNdInGs/tRuStEdAcCeSsRoLeBiNdInGnAmE", + Expected: &TrustedAccessRoleBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRnAmE", + TrustedAccessRoleBindingName: "tRuStEdAcCeSsRoLeBiNdInGnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRnAmE/tRuStEdAcCeSsRoLeBiNdInGs/tRuStEdAcCeSsRoLeBiNdInGnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTrustedAccessRoleBindingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.TrustedAccessRoleBindingName != v.Expected.TrustedAccessRoleBindingName { + t.Fatalf("Expected %q but got %q for TrustedAccessRoleBindingName", v.Expected.TrustedAccessRoleBindingName, actual.TrustedAccessRoleBindingName) + } + + } +} + +func TestSegmentsForTrustedAccessRoleBindingId(t *testing.T) { + segments := TrustedAccessRoleBindingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TrustedAccessRoleBindingId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/method_rolebindingscreateorupdate.go b/resource-manager/containerservice/2025-02-01/trustedaccess/method_rolebindingscreateorupdate.go new file mode 100644 index 00000000000..682a9388eae --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/method_rolebindingscreateorupdate.go @@ -0,0 +1,75 @@ +package trustedaccess + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoleBindingsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *TrustedAccessRoleBinding +} + +// RoleBindingsCreateOrUpdate ... +func (c TrustedAccessClient) RoleBindingsCreateOrUpdate(ctx context.Context, id TrustedAccessRoleBindingId, input TrustedAccessRoleBinding) (result RoleBindingsCreateOrUpdateOperationResponse, 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 +} + +// RoleBindingsCreateOrUpdateThenPoll performs RoleBindingsCreateOrUpdate then polls until it's completed +func (c TrustedAccessClient) RoleBindingsCreateOrUpdateThenPoll(ctx context.Context, id TrustedAccessRoleBindingId, input TrustedAccessRoleBinding) error { + result, err := c.RoleBindingsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RoleBindingsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RoleBindingsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/method_rolebindingsdelete.go b/resource-manager/containerservice/2025-02-01/trustedaccess/method_rolebindingsdelete.go new file mode 100644 index 00000000000..7107d14f6f5 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/method_rolebindingsdelete.go @@ -0,0 +1,70 @@ +package trustedaccess + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoleBindingsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RoleBindingsDelete ... +func (c TrustedAccessClient) RoleBindingsDelete(ctx context.Context, id TrustedAccessRoleBindingId) (result RoleBindingsDeleteOperationResponse, 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 +} + +// RoleBindingsDeleteThenPoll performs RoleBindingsDelete then polls until it's completed +func (c TrustedAccessClient) RoleBindingsDeleteThenPoll(ctx context.Context, id TrustedAccessRoleBindingId) error { + result, err := c.RoleBindingsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RoleBindingsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RoleBindingsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/method_rolebindingsget.go b/resource-manager/containerservice/2025-02-01/trustedaccess/method_rolebindingsget.go new file mode 100644 index 00000000000..d70aa4cbfb4 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/method_rolebindingsget.go @@ -0,0 +1,53 @@ +package trustedaccess + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoleBindingsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TrustedAccessRoleBinding +} + +// RoleBindingsGet ... +func (c TrustedAccessClient) RoleBindingsGet(ctx context.Context, id TrustedAccessRoleBindingId) (result RoleBindingsGetOperationResponse, 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 TrustedAccessRoleBinding + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/method_rolebindingslist.go b/resource-manager/containerservice/2025-02-01/trustedaccess/method_rolebindingslist.go new file mode 100644 index 00000000000..8c24b744a5d --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/method_rolebindingslist.go @@ -0,0 +1,106 @@ +package trustedaccess + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoleBindingsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TrustedAccessRoleBinding +} + +type RoleBindingsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []TrustedAccessRoleBinding +} + +type RoleBindingsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RoleBindingsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RoleBindingsList ... +func (c TrustedAccessClient) RoleBindingsList(ctx context.Context, id commonids.KubernetesClusterId) (result RoleBindingsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RoleBindingsListCustomPager{}, + Path: fmt.Sprintf("%s/trustedAccessRoleBindings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TrustedAccessRoleBinding `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RoleBindingsListComplete retrieves all the results into a single object +func (c TrustedAccessClient) RoleBindingsListComplete(ctx context.Context, id commonids.KubernetesClusterId) (RoleBindingsListCompleteResult, error) { + return c.RoleBindingsListCompleteMatchingPredicate(ctx, id, TrustedAccessRoleBindingOperationPredicate{}) +} + +// RoleBindingsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TrustedAccessClient) RoleBindingsListCompleteMatchingPredicate(ctx context.Context, id commonids.KubernetesClusterId, predicate TrustedAccessRoleBindingOperationPredicate) (result RoleBindingsListCompleteResult, err error) { + items := make([]TrustedAccessRoleBinding, 0) + + resp, err := c.RoleBindingsList(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 = RoleBindingsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/method_roleslist.go b/resource-manager/containerservice/2025-02-01/trustedaccess/method_roleslist.go new file mode 100644 index 00000000000..211cbf901bc --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/method_roleslist.go @@ -0,0 +1,105 @@ +package trustedaccess + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RolesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TrustedAccessRole +} + +type RolesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []TrustedAccessRole +} + +type RolesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RolesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RolesList ... +func (c TrustedAccessClient) RolesList(ctx context.Context, id LocationId) (result RolesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RolesListCustomPager{}, + Path: fmt.Sprintf("%s/trustedAccessRoles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TrustedAccessRole `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RolesListComplete retrieves all the results into a single object +func (c TrustedAccessClient) RolesListComplete(ctx context.Context, id LocationId) (RolesListCompleteResult, error) { + return c.RolesListCompleteMatchingPredicate(ctx, id, TrustedAccessRoleOperationPredicate{}) +} + +// RolesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TrustedAccessClient) RolesListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate TrustedAccessRoleOperationPredicate) (result RolesListCompleteResult, err error) { + items := make([]TrustedAccessRole, 0) + + resp, err := c.RolesList(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 = RolesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/model_trustedaccessrole.go b/resource-manager/containerservice/2025-02-01/trustedaccess/model_trustedaccessrole.go new file mode 100644 index 00000000000..a24a7344c12 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/model_trustedaccessrole.go @@ -0,0 +1,10 @@ +package trustedaccess + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrustedAccessRole struct { + Name *string `json:"name,omitempty"` + Rules *[]TrustedAccessRoleRule `json:"rules,omitempty"` + SourceResourceType *string `json:"sourceResourceType,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/model_trustedaccessrolebinding.go b/resource-manager/containerservice/2025-02-01/trustedaccess/model_trustedaccessrolebinding.go new file mode 100644 index 00000000000..36c110999f6 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/model_trustedaccessrolebinding.go @@ -0,0 +1,16 @@ +package trustedaccess + +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 TrustedAccessRoleBinding struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties TrustedAccessRoleBindingProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/model_trustedaccessrolebindingproperties.go b/resource-manager/containerservice/2025-02-01/trustedaccess/model_trustedaccessrolebindingproperties.go new file mode 100644 index 00000000000..b432519d7cc --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/model_trustedaccessrolebindingproperties.go @@ -0,0 +1,10 @@ +package trustedaccess + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrustedAccessRoleBindingProperties struct { + ProvisioningState *TrustedAccessRoleBindingProvisioningState `json:"provisioningState,omitempty"` + Roles []string `json:"roles"` + SourceResourceId string `json:"sourceResourceId"` +} diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/model_trustedaccessrolerule.go b/resource-manager/containerservice/2025-02-01/trustedaccess/model_trustedaccessrolerule.go new file mode 100644 index 00000000000..808af096d0a --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/model_trustedaccessrolerule.go @@ -0,0 +1,12 @@ +package trustedaccess + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrustedAccessRoleRule struct { + ApiGroups *[]string `json:"apiGroups,omitempty"` + NonResourceURLs *[]string `json:"nonResourceURLs,omitempty"` + ResourceNames *[]string `json:"resourceNames,omitempty"` + Resources *[]string `json:"resources,omitempty"` + Verbs *[]string `json:"verbs,omitempty"` +} diff --git a/resource-manager/containerservice/2025-02-01/trustedaccess/predicates.go b/resource-manager/containerservice/2025-02-01/trustedaccess/predicates.go new file mode 100644 index 00000000000..6bab96a78b7 --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/predicates.go @@ -0,0 +1,45 @@ +package trustedaccess + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrustedAccessRoleOperationPredicate struct { + Name *string + SourceResourceType *string +} + +func (p TrustedAccessRoleOperationPredicate) Matches(input TrustedAccessRole) bool { + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.SourceResourceType != nil && (input.SourceResourceType == nil || *p.SourceResourceType != *input.SourceResourceType) { + return false + } + + return true +} + +type TrustedAccessRoleBindingOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p TrustedAccessRoleBindingOperationPredicate) Matches(input TrustedAccessRoleBinding) 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/containerservice/2025-02-01/trustedaccess/version.go b/resource-manager/containerservice/2025-02-01/trustedaccess/version.go new file mode 100644 index 00000000000..933efb669cc --- /dev/null +++ b/resource-manager/containerservice/2025-02-01/trustedaccess/version.go @@ -0,0 +1,10 @@ +package trustedaccess + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/trustedaccess/2025-02-01" +} diff --git a/resource-manager/eventhub/2024-01-01/namespacesnetworksecurityperimeterconfigurations/README.md b/resource-manager/eventhub/2024-01-01/namespacesnetworksecurityperimeterconfigurations/README.md index a611bfe47ac..5bc4890310d 100644 --- a/resource-manager/eventhub/2024-01-01/namespacesnetworksecurityperimeterconfigurations/README.md +++ b/resource-manager/eventhub/2024-01-01/namespacesnetworksecurityperimeterconfigurations/README.md @@ -46,3 +46,19 @@ if err := client.NetworkSecurityPerimeterConfigurationsCreateOrUpdateThenPoll(ct // handle the error } ``` + + +### Example Usage: `NamespacesNetworkSecurityPerimeterConfigurationsClient.NetworkSecurityPerimeterConfigurationsresourceAssociationName` + +```go +ctx := context.TODO() +id := namespacesnetworksecurityperimeterconfigurations.NewNetworkSecurityPerimeterConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "namespaceName", "networkSecurityPerimeterConfigurationName") + +read, err := client.NetworkSecurityPerimeterConfigurationsresourceAssociationName(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/eventhub/2024-01-01/namespacesnetworksecurityperimeterconfigurations/method_networksecurityperimeterconfigurationsresourceassociationname.go b/resource-manager/eventhub/2024-01-01/namespacesnetworksecurityperimeterconfigurations/method_networksecurityperimeterconfigurationsresourceassociationname.go new file mode 100644 index 00000000000..6fab6d28c0b --- /dev/null +++ b/resource-manager/eventhub/2024-01-01/namespacesnetworksecurityperimeterconfigurations/method_networksecurityperimeterconfigurationsresourceassociationname.go @@ -0,0 +1,53 @@ +package namespacesnetworksecurityperimeterconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterConfigurationsresourceAssociationNameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkSecurityPerimeterConfiguration +} + +// NetworkSecurityPerimeterConfigurationsresourceAssociationName ... +func (c NamespacesNetworkSecurityPerimeterConfigurationsClient) NetworkSecurityPerimeterConfigurationsresourceAssociationName(ctx context.Context, id NetworkSecurityPerimeterConfigurationId) (result NetworkSecurityPerimeterConfigurationsresourceAssociationNameOperationResponse, 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/network/2024-05-01/networkmanagereffectiveconnectivityconfiguration/constants.go b/resource-manager/network/2024-05-01/networkmanagereffectiveconnectivityconfiguration/constants.go index 9007e4a33df..caa8b3c8747 100644 --- a/resource-manager/network/2024-05-01/networkmanagereffectiveconnectivityconfiguration/constants.go +++ b/resource-manager/network/2024-05-01/networkmanagereffectiveconnectivityconfiguration/constants.go @@ -217,8 +217,6 @@ func parseIsGlobal(input string) (*IsGlobal, error) { type ProvisioningState string const ( - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" ProvisioningStateDeleting ProvisioningState = "Deleting" ProvisioningStateFailed ProvisioningState = "Failed" ProvisioningStateSucceeded ProvisioningState = "Succeeded" @@ -227,8 +225,6 @@ const ( func PossibleValuesForProvisioningState() []string { return []string{ - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), string(ProvisioningStateDeleting), string(ProvisioningStateFailed), string(ProvisioningStateSucceeded), @@ -251,8 +247,6 @@ func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, "deleting": ProvisioningStateDeleting, "failed": ProvisioningStateFailed, "succeeded": ProvisioningStateSucceeded, diff --git a/resource-manager/network/2024-05-01/networkmanagereffectivesecurityadminrules/constants.go b/resource-manager/network/2024-05-01/networkmanagereffectivesecurityadminrules/constants.go index 6dbd1e6db74..67086d778e3 100644 --- a/resource-manager/network/2024-05-01/networkmanagereffectivesecurityadminrules/constants.go +++ b/resource-manager/network/2024-05-01/networkmanagereffectivesecurityadminrules/constants.go @@ -138,8 +138,6 @@ func parseGroupMemberType(input string) (*GroupMemberType, error) { type ProvisioningState string const ( - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" ProvisioningStateDeleting ProvisioningState = "Deleting" ProvisioningStateFailed ProvisioningState = "Failed" ProvisioningStateSucceeded ProvisioningState = "Succeeded" @@ -148,8 +146,6 @@ const ( func PossibleValuesForProvisioningState() []string { return []string{ - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), string(ProvisioningStateDeleting), string(ProvisioningStateFailed), string(ProvisioningStateSucceeded), @@ -172,8 +168,6 @@ func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, "deleting": ProvisioningStateDeleting, "failed": ProvisioningStateFailed, "succeeded": ProvisioningStateSucceeded, diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/constants.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/constants.go index 793caeabedc..c9291fb2fab 100644 --- a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/constants.go +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/constants.go @@ -138,8 +138,6 @@ func parseGroupMemberType(input string) (*GroupMemberType, error) { type ProvisioningState string const ( - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" ProvisioningStateDeleting ProvisioningState = "Deleting" ProvisioningStateFailed ProvisioningState = "Failed" ProvisioningStateSucceeded ProvisioningState = "Succeeded" @@ -148,8 +146,6 @@ const ( func PossibleValuesForProvisioningState() []string { return []string{ - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), string(ProvisioningStateDeleting), string(ProvisioningStateFailed), string(ProvisioningStateSucceeded), @@ -172,8 +168,6 @@ func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, "deleting": ProvisioningStateDeleting, "failed": ProvisioningStateFailed, "succeeded": ProvisioningStateSucceeded, diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/constants.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/constants.go index 451770f8cbb..8195863c49a 100644 --- a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/constants.go +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/constants.go @@ -340,8 +340,6 @@ func parsePeeringEnforcement(input string) (*PeeringEnforcement, error) { type ProvisioningState string const ( - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" ProvisioningStateDeleting ProvisioningState = "Deleting" ProvisioningStateFailed ProvisioningState = "Failed" ProvisioningStateSucceeded ProvisioningState = "Succeeded" @@ -350,8 +348,6 @@ const ( func PossibleValuesForProvisioningState() []string { return []string{ - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), string(ProvisioningStateDeleting), string(ProvisioningStateFailed), string(ProvisioningStateSucceeded), @@ -374,8 +370,6 @@ func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, "deleting": ProvisioningStateDeleting, "failed": ProvisioningStateFailed, "succeeded": ProvisioningStateSucceeded, diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/client.go new file mode 100644 index 00000000000..be7a7a65b4f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/client.go @@ -0,0 +1,298 @@ +package v2025_02_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/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/operations" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + ClusterRecoveryPoint *clusterrecoverypoint.ClusterRecoveryPointClient + ClusterRecoveryPoints *clusterrecoverypoints.ClusterRecoveryPointsClient + MigrationRecoveryPoints *migrationrecoverypoints.MigrationRecoveryPointsClient + Operations *operations.OperationsClient + RecoveryPoints *recoverypoints.RecoveryPointsClient + ReplicationAlertSettings *replicationalertsettings.ReplicationAlertSettingsClient + ReplicationAppliances *replicationappliances.ReplicationAppliancesClient + ReplicationEligibilityResults *replicationeligibilityresults.ReplicationEligibilityResultsClient + ReplicationEvents *replicationevents.ReplicationEventsClient + ReplicationFabrics *replicationfabrics.ReplicationFabricsClient + ReplicationJobs *replicationjobs.ReplicationJobsClient + ReplicationLogicalNetworks *replicationlogicalnetworks.ReplicationLogicalNetworksClient + ReplicationMigrationItems *replicationmigrationitems.ReplicationMigrationItemsClient + ReplicationNetworkMappings *replicationnetworkmappings.ReplicationNetworkMappingsClient + ReplicationNetworks *replicationnetworks.ReplicationNetworksClient + ReplicationPolicies *replicationpolicies.ReplicationPoliciesClient + ReplicationProtectableItems *replicationprotectableitems.ReplicationProtectableItemsClient + ReplicationProtectedItems *replicationprotecteditems.ReplicationProtectedItemsClient + ReplicationProtectionClusters *replicationprotectionclusters.ReplicationProtectionClustersClient + ReplicationProtectionContainerMappings *replicationprotectioncontainermappings.ReplicationProtectionContainerMappingsClient + ReplicationProtectionContainers *replicationprotectioncontainers.ReplicationProtectionContainersClient + ReplicationProtectionIntents *replicationprotectionintents.ReplicationProtectionIntentsClient + ReplicationRecoveryPlans *replicationrecoveryplans.ReplicationRecoveryPlansClient + ReplicationRecoveryServicesProviders *replicationrecoveryservicesproviders.ReplicationRecoveryServicesProvidersClient + ReplicationStorageClassificationMappings *replicationstorageclassificationmappings.ReplicationStorageClassificationMappingsClient + ReplicationStorageClassifications *replicationstorageclassifications.ReplicationStorageClassificationsClient + ReplicationVaultHealth *replicationvaulthealth.ReplicationVaultHealthClient + ReplicationVaultSetting *replicationvaultsetting.ReplicationVaultSettingClient + ReplicationvCenters *replicationvcenters.ReplicationvCentersClient + SupportedOperatingSystems *supportedoperatingsystems.SupportedOperatingSystemsClient + TargetComputeSizes *targetcomputesizes.TargetComputeSizesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + clusterRecoveryPointClient, err := clusterrecoverypoint.NewClusterRecoveryPointClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ClusterRecoveryPoint client: %+v", err) + } + configureFunc(clusterRecoveryPointClient.Client) + + clusterRecoveryPointsClient, err := clusterrecoverypoints.NewClusterRecoveryPointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ClusterRecoveryPoints client: %+v", err) + } + configureFunc(clusterRecoveryPointsClient.Client) + + migrationRecoveryPointsClient, err := migrationrecoverypoints.NewMigrationRecoveryPointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MigrationRecoveryPoints client: %+v", err) + } + configureFunc(migrationRecoveryPointsClient.Client) + + operationsClient, err := operations.NewOperationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Operations client: %+v", err) + } + configureFunc(operationsClient.Client) + + recoveryPointsClient, err := recoverypoints.NewRecoveryPointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RecoveryPoints client: %+v", err) + } + configureFunc(recoveryPointsClient.Client) + + replicationAlertSettingsClient, err := replicationalertsettings.NewReplicationAlertSettingsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationAlertSettings client: %+v", err) + } + configureFunc(replicationAlertSettingsClient.Client) + + replicationAppliancesClient, err := replicationappliances.NewReplicationAppliancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationAppliances client: %+v", err) + } + configureFunc(replicationAppliancesClient.Client) + + replicationEligibilityResultsClient, err := replicationeligibilityresults.NewReplicationEligibilityResultsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationEligibilityResults client: %+v", err) + } + configureFunc(replicationEligibilityResultsClient.Client) + + replicationEventsClient, err := replicationevents.NewReplicationEventsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationEvents client: %+v", err) + } + configureFunc(replicationEventsClient.Client) + + replicationFabricsClient, err := replicationfabrics.NewReplicationFabricsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationFabrics client: %+v", err) + } + configureFunc(replicationFabricsClient.Client) + + replicationJobsClient, err := replicationjobs.NewReplicationJobsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationJobs client: %+v", err) + } + configureFunc(replicationJobsClient.Client) + + replicationLogicalNetworksClient, err := replicationlogicalnetworks.NewReplicationLogicalNetworksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationLogicalNetworks client: %+v", err) + } + configureFunc(replicationLogicalNetworksClient.Client) + + replicationMigrationItemsClient, err := replicationmigrationitems.NewReplicationMigrationItemsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationMigrationItems client: %+v", err) + } + configureFunc(replicationMigrationItemsClient.Client) + + replicationNetworkMappingsClient, err := replicationnetworkmappings.NewReplicationNetworkMappingsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationNetworkMappings client: %+v", err) + } + configureFunc(replicationNetworkMappingsClient.Client) + + replicationNetworksClient, err := replicationnetworks.NewReplicationNetworksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationNetworks client: %+v", err) + } + configureFunc(replicationNetworksClient.Client) + + replicationPoliciesClient, err := replicationpolicies.NewReplicationPoliciesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationPolicies client: %+v", err) + } + configureFunc(replicationPoliciesClient.Client) + + replicationProtectableItemsClient, err := replicationprotectableitems.NewReplicationProtectableItemsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectableItems client: %+v", err) + } + configureFunc(replicationProtectableItemsClient.Client) + + replicationProtectedItemsClient, err := replicationprotecteditems.NewReplicationProtectedItemsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectedItems client: %+v", err) + } + configureFunc(replicationProtectedItemsClient.Client) + + replicationProtectionClustersClient, err := replicationprotectionclusters.NewReplicationProtectionClustersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectionClusters client: %+v", err) + } + configureFunc(replicationProtectionClustersClient.Client) + + replicationProtectionContainerMappingsClient, err := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectionContainerMappings client: %+v", err) + } + configureFunc(replicationProtectionContainerMappingsClient.Client) + + replicationProtectionContainersClient, err := replicationprotectioncontainers.NewReplicationProtectionContainersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectionContainers client: %+v", err) + } + configureFunc(replicationProtectionContainersClient.Client) + + replicationProtectionIntentsClient, err := replicationprotectionintents.NewReplicationProtectionIntentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationProtectionIntents client: %+v", err) + } + configureFunc(replicationProtectionIntentsClient.Client) + + replicationRecoveryPlansClient, err := replicationrecoveryplans.NewReplicationRecoveryPlansClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationRecoveryPlans client: %+v", err) + } + configureFunc(replicationRecoveryPlansClient.Client) + + replicationRecoveryServicesProvidersClient, err := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProvidersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationRecoveryServicesProviders client: %+v", err) + } + configureFunc(replicationRecoveryServicesProvidersClient.Client) + + replicationStorageClassificationMappingsClient, err := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationStorageClassificationMappings client: %+v", err) + } + configureFunc(replicationStorageClassificationMappingsClient.Client) + + replicationStorageClassificationsClient, err := replicationstorageclassifications.NewReplicationStorageClassificationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationStorageClassifications client: %+v", err) + } + configureFunc(replicationStorageClassificationsClient.Client) + + replicationVaultHealthClient, err := replicationvaulthealth.NewReplicationVaultHealthClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationVaultHealth client: %+v", err) + } + configureFunc(replicationVaultHealthClient.Client) + + replicationVaultSettingClient, err := replicationvaultsetting.NewReplicationVaultSettingClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationVaultSetting client: %+v", err) + } + configureFunc(replicationVaultSettingClient.Client) + + replicationvCentersClient, err := replicationvcenters.NewReplicationvCentersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationvCenters client: %+v", err) + } + configureFunc(replicationvCentersClient.Client) + + supportedOperatingSystemsClient, err := supportedoperatingsystems.NewSupportedOperatingSystemsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SupportedOperatingSystems client: %+v", err) + } + configureFunc(supportedOperatingSystemsClient.Client) + + targetComputeSizesClient, err := targetcomputesizes.NewTargetComputeSizesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building TargetComputeSizes client: %+v", err) + } + configureFunc(targetComputeSizesClient.Client) + + return &Client{ + ClusterRecoveryPoint: clusterRecoveryPointClient, + ClusterRecoveryPoints: clusterRecoveryPointsClient, + MigrationRecoveryPoints: migrationRecoveryPointsClient, + Operations: operationsClient, + RecoveryPoints: recoveryPointsClient, + ReplicationAlertSettings: replicationAlertSettingsClient, + ReplicationAppliances: replicationAppliancesClient, + ReplicationEligibilityResults: replicationEligibilityResultsClient, + ReplicationEvents: replicationEventsClient, + ReplicationFabrics: replicationFabricsClient, + ReplicationJobs: replicationJobsClient, + ReplicationLogicalNetworks: replicationLogicalNetworksClient, + ReplicationMigrationItems: replicationMigrationItemsClient, + ReplicationNetworkMappings: replicationNetworkMappingsClient, + ReplicationNetworks: replicationNetworksClient, + ReplicationPolicies: replicationPoliciesClient, + ReplicationProtectableItems: replicationProtectableItemsClient, + ReplicationProtectedItems: replicationProtectedItemsClient, + ReplicationProtectionClusters: replicationProtectionClustersClient, + ReplicationProtectionContainerMappings: replicationProtectionContainerMappingsClient, + ReplicationProtectionContainers: replicationProtectionContainersClient, + ReplicationProtectionIntents: replicationProtectionIntentsClient, + ReplicationRecoveryPlans: replicationRecoveryPlansClient, + ReplicationRecoveryServicesProviders: replicationRecoveryServicesProvidersClient, + ReplicationStorageClassificationMappings: replicationStorageClassificationMappingsClient, + ReplicationStorageClassifications: replicationStorageClassificationsClient, + ReplicationVaultHealth: replicationVaultHealthClient, + ReplicationVaultSetting: replicationVaultSettingClient, + ReplicationvCenters: replicationvCentersClient, + SupportedOperatingSystems: supportedOperatingSystemsClient, + TargetComputeSizes: targetComputeSizesClient, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/README.md new file mode 100644 index 00000000000..d86bd38ed8e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint` Documentation + +The `clusterrecoverypoint` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint" +``` + + +### Client Initialization + +```go +client := clusterrecoverypoint.NewClusterRecoveryPointClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ClusterRecoveryPointClient.Get` + +```go +ctx := context.TODO() +id := clusterrecoverypoint.NewReplicationProtectionClusterRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName", "recoveryPointName") + +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 +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/client.go new file mode 100644 index 00000000000..c1b0f34229e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/client.go @@ -0,0 +1,26 @@ +package clusterrecoverypoint + +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 ClusterRecoveryPointClient struct { + Client *resourcemanager.Client +} + +func NewClusterRecoveryPointClientWithBaseURI(sdkApi sdkEnv.Api) (*ClusterRecoveryPointClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "clusterrecoverypoint", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ClusterRecoveryPointClient: %+v", err) + } + + return &ClusterRecoveryPointClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/constants.go new file mode 100644 index 00000000000..fc7e79ed34c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/constants.go @@ -0,0 +1,92 @@ +package clusterrecoverypoint + +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 ClusterRecoveryPointType string + +const ( + ClusterRecoveryPointTypeApplicationConsistent ClusterRecoveryPointType = "ApplicationConsistent" + ClusterRecoveryPointTypeCrashConsistent ClusterRecoveryPointType = "CrashConsistent" + ClusterRecoveryPointTypeNotSpecified ClusterRecoveryPointType = "NotSpecified" +) + +func PossibleValuesForClusterRecoveryPointType() []string { + return []string{ + string(ClusterRecoveryPointTypeApplicationConsistent), + string(ClusterRecoveryPointTypeCrashConsistent), + string(ClusterRecoveryPointTypeNotSpecified), + } +} + +func (s *ClusterRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterRecoveryPointType(input string) (*ClusterRecoveryPointType, error) { + vals := map[string]ClusterRecoveryPointType{ + "applicationconsistent": ClusterRecoveryPointTypeApplicationConsistent, + "crashconsistent": ClusterRecoveryPointTypeCrashConsistent, + "notspecified": ClusterRecoveryPointTypeNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterRecoveryPointType(input) + return &out, nil +} + +type RecoveryPointSyncType string + +const ( + RecoveryPointSyncTypeMultiVMSyncRecoveryPoint RecoveryPointSyncType = "MultiVmSyncRecoveryPoint" +) + +func PossibleValuesForRecoveryPointSyncType() []string { + return []string{ + string(RecoveryPointSyncTypeMultiVMSyncRecoveryPoint), + } +} + +func (s *RecoveryPointSyncType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPointSyncType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPointSyncType(input string) (*RecoveryPointSyncType, error) { + vals := map[string]RecoveryPointSyncType{ + "multivmsyncrecoverypoint": RecoveryPointSyncTypeMultiVMSyncRecoveryPoint, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointSyncType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/id_replicationprotectionclusterrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/id_replicationprotectionclusterrecoverypoint.go new file mode 100644 index 00000000000..cb85902f9a5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/id_replicationprotectionclusterrecoverypoint.go @@ -0,0 +1,166 @@ +package clusterrecoverypoint + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectionClusterRecoveryPointId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionClusterRecoveryPointId{} + +// ReplicationProtectionClusterRecoveryPointId is a struct representing the Resource ID for a Replication Protection Cluster Recovery Point +type ReplicationProtectionClusterRecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectionClusterName string + RecoveryPointName string +} + +// NewReplicationProtectionClusterRecoveryPointID returns a new ReplicationProtectionClusterRecoveryPointId struct +func NewReplicationProtectionClusterRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectionClusterName string, recoveryPointName string) ReplicationProtectionClusterRecoveryPointId { + return ReplicationProtectionClusterRecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectionClusterName: replicationProtectionClusterName, + RecoveryPointName: recoveryPointName, + } +} + +// ParseReplicationProtectionClusterRecoveryPointID parses 'input' into a ReplicationProtectionClusterRecoveryPointId +func ParseReplicationProtectionClusterRecoveryPointID(input string) (*ReplicationProtectionClusterRecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionClusterRecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionClusterRecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionClusterRecoveryPointIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionClusterRecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionClusterRecoveryPointIDInsensitively(input string) (*ReplicationProtectionClusterRecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionClusterRecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionClusterRecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionClusterRecoveryPointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectionClusterName, ok = input.Parsed["replicationProtectionClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionClusterName", input) + } + + if id.RecoveryPointName, ok = input.Parsed["recoveryPointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recoveryPointName", input) + } + + return nil +} + +// ValidateReplicationProtectionClusterRecoveryPointID checks that 'input' can be parsed as a Replication Protection Cluster Recovery Point ID +func ValidateReplicationProtectionClusterRecoveryPointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectionClusterRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Cluster Recovery Point ID +func (id ReplicationProtectionClusterRecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectionClusters/%s/recoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectionClusterName, id.RecoveryPointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Cluster Recovery Point ID +func (id ReplicationProtectionClusterRecoveryPointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectionClusters", "replicationProtectionClusters", "replicationProtectionClusters"), + resourceids.UserSpecifiedSegment("replicationProtectionClusterName", "replicationProtectionClusterName"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointName", "recoveryPointName"), + } +} + +// String returns a human-readable description of this Replication Protection Cluster Recovery Point ID +func (id ReplicationProtectionClusterRecoveryPointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protection Cluster Name: %q", id.ReplicationProtectionClusterName), + fmt.Sprintf("Recovery Point Name: %q", id.RecoveryPointName), + } + return fmt.Sprintf("Replication Protection Cluster Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/id_replicationprotectionclusterrecoverypoint_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/id_replicationprotectionclusterrecoverypoint_test.go new file mode 100644 index 00000000000..976ddec572b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/id_replicationprotectionclusterrecoverypoint_test.go @@ -0,0 +1,462 @@ +package clusterrecoverypoint + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectionClusterRecoveryPointId{} + +func TestNewReplicationProtectionClusterRecoveryPointID(t *testing.T) { + id := NewReplicationProtectionClusterRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName", "recoveryPointName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectionClusterName != "replicationProtectionClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionClusterName'", id.ReplicationProtectionClusterName, "replicationProtectionClusterName") + } + + if id.RecoveryPointName != "recoveryPointName" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointName'", id.RecoveryPointName, "recoveryPointName") + } +} + +func TestFormatReplicationProtectionClusterRecoveryPointID(t *testing.T) { + actual := NewReplicationProtectionClusterRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName", "recoveryPointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/recoveryPoints/recoveryPointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionClusterRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionClusterRecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/recoveryPoints/recoveryPointName", + Expected: &ReplicationProtectionClusterRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionClusterName: "replicationProtectionClusterName", + RecoveryPointName: "recoveryPointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/recoveryPoints/recoveryPointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionClusterRecoveryPointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionClusterName != v.Expected.ReplicationProtectionClusterName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionClusterName", v.Expected.ReplicationProtectionClusterName, actual.ReplicationProtectionClusterName) + } + + if actual.RecoveryPointName != v.Expected.RecoveryPointName { + t.Fatalf("Expected %q but got %q for RecoveryPointName", v.Expected.RecoveryPointName, actual.RecoveryPointName) + } + + } +} + +func TestParseReplicationProtectionClusterRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionClusterRecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/recoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/recoveryPoints/recoveryPointName", + Expected: &ReplicationProtectionClusterRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionClusterName: "replicationProtectionClusterName", + RecoveryPointName: "recoveryPointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/recoveryPoints/recoveryPointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE/rEcOvErYpOiNtS/rEcOvErYpOiNtNaMe", + Expected: &ReplicationProtectionClusterRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectionClusterName: "rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE", + RecoveryPointName: "rEcOvErYpOiNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE/rEcOvErYpOiNtS/rEcOvErYpOiNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionClusterRecoveryPointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionClusterName != v.Expected.ReplicationProtectionClusterName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionClusterName", v.Expected.ReplicationProtectionClusterName, actual.ReplicationProtectionClusterName) + } + + if actual.RecoveryPointName != v.Expected.RecoveryPointName { + t.Fatalf("Expected %q but got %q for RecoveryPointName", v.Expected.RecoveryPointName, actual.RecoveryPointName) + } + + } +} + +func TestSegmentsForReplicationProtectionClusterRecoveryPointId(t *testing.T) { + segments := ReplicationProtectionClusterRecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionClusterRecoveryPointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/method_get.go new file mode 100644 index 00000000000..a7d9c730960 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/method_get.go @@ -0,0 +1,53 @@ +package clusterrecoverypoint + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ClusterRecoveryPoint +} + +// Get ... +func (c ClusterRecoveryPointClient) Get(ctx context.Context, id ReplicationProtectionClusterRecoveryPointId) (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 ClusterRecoveryPoint + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/model_a2aclusterrecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/model_a2aclusterrecoverypointdetails.go new file mode 100644 index 00000000000..db94ef72233 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/model_a2aclusterrecoverypointdetails.go @@ -0,0 +1,51 @@ +package clusterrecoverypoint + +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 _ ClusterProviderSpecificRecoveryPointDetails = A2AClusterRecoveryPointDetails{} + +type A2AClusterRecoveryPointDetails struct { + Nodes *[]string `json:"nodes,omitempty"` + RecoveryPointSyncType *RecoveryPointSyncType `json:"recoveryPointSyncType,omitempty"` + + // Fields inherited from ClusterProviderSpecificRecoveryPointDetails + + InstanceType string `json:"instanceType"` +} + +func (s A2AClusterRecoveryPointDetails) ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl { + return BaseClusterProviderSpecificRecoveryPointDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AClusterRecoveryPointDetails{} + +func (s A2AClusterRecoveryPointDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AClusterRecoveryPointDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AClusterRecoveryPointDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AClusterRecoveryPointDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AClusterRecoveryPointDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/model_clusterproviderspecificrecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/model_clusterproviderspecificrecoverypointdetails.go new file mode 100644 index 00000000000..bfcc5f63051 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/model_clusterproviderspecificrecoverypointdetails.go @@ -0,0 +1,75 @@ +package clusterrecoverypoint + +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 ClusterProviderSpecificRecoveryPointDetails interface { + ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl +} + +var _ ClusterProviderSpecificRecoveryPointDetails = BaseClusterProviderSpecificRecoveryPointDetailsImpl{} + +type BaseClusterProviderSpecificRecoveryPointDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseClusterProviderSpecificRecoveryPointDetailsImpl) ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl { + return s +} + +var _ ClusterProviderSpecificRecoveryPointDetails = RawClusterProviderSpecificRecoveryPointDetailsImpl{} + +// RawClusterProviderSpecificRecoveryPointDetailsImpl 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 RawClusterProviderSpecificRecoveryPointDetailsImpl struct { + clusterProviderSpecificRecoveryPointDetails BaseClusterProviderSpecificRecoveryPointDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawClusterProviderSpecificRecoveryPointDetailsImpl) ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl { + return s.clusterProviderSpecificRecoveryPointDetails +} + +func UnmarshalClusterProviderSpecificRecoveryPointDetailsImplementation(input []byte) (ClusterProviderSpecificRecoveryPointDetails, 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 ClusterProviderSpecificRecoveryPointDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AClusterRecoveryPointDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AClusterRecoveryPointDetails: %+v", err) + } + return out, nil + } + + var parent BaseClusterProviderSpecificRecoveryPointDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseClusterProviderSpecificRecoveryPointDetailsImpl: %+v", err) + } + + return RawClusterProviderSpecificRecoveryPointDetailsImpl{ + clusterProviderSpecificRecoveryPointDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/model_clusterrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/model_clusterrecoverypoint.go new file mode 100644 index 00000000000..26af7a4d2f4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/model_clusterrecoverypoint.go @@ -0,0 +1,11 @@ +package clusterrecoverypoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterRecoveryPoint struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ClusterRecoveryPointProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/model_clusterrecoverypointproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/model_clusterrecoverypointproperties.go new file mode 100644 index 00000000000..2ebe7e7f91a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/model_clusterrecoverypointproperties.go @@ -0,0 +1,60 @@ +package clusterrecoverypoint + +import ( + "encoding/json" + "fmt" + "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 ClusterRecoveryPointProperties struct { + ProviderSpecificDetails ClusterProviderSpecificRecoveryPointDetails `json:"providerSpecificDetails"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *ClusterRecoveryPointType `json:"recoveryPointType,omitempty"` +} + +func (o *ClusterRecoveryPointProperties) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ClusterRecoveryPointProperties) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} + +var _ json.Unmarshaler = &ClusterRecoveryPointProperties{} + +func (s *ClusterRecoveryPointProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *ClusterRecoveryPointType `json:"recoveryPointType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.RecoveryPointTime = decoded.RecoveryPointTime + s.RecoveryPointType = decoded.RecoveryPointType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ClusterRecoveryPointProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalClusterProviderSpecificRecoveryPointDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ClusterRecoveryPointProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/version.go new file mode 100644 index 00000000000..c01433ae160 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoint/version.go @@ -0,0 +1,10 @@ +package clusterrecoverypoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/clusterrecoverypoint/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/README.md new file mode 100644 index 00000000000..80d91011819 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints` Documentation + +The `clusterrecoverypoints` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints" +``` + + +### Client Initialization + +```go +client := clusterrecoverypoints.NewClusterRecoveryPointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ClusterRecoveryPointsClient.ListByReplicationProtectionCluster` + +```go +ctx := context.TODO() +id := clusterrecoverypoints.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +// alternatively `client.ListByReplicationProtectionCluster(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectionClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/client.go new file mode 100644 index 00000000000..9ffb1251268 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/client.go @@ -0,0 +1,26 @@ +package clusterrecoverypoints + +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 ClusterRecoveryPointsClient struct { + Client *resourcemanager.Client +} + +func NewClusterRecoveryPointsClientWithBaseURI(sdkApi sdkEnv.Api) (*ClusterRecoveryPointsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "clusterrecoverypoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ClusterRecoveryPointsClient: %+v", err) + } + + return &ClusterRecoveryPointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/constants.go new file mode 100644 index 00000000000..5c894467f6c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/constants.go @@ -0,0 +1,92 @@ +package clusterrecoverypoints + +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 ClusterRecoveryPointType string + +const ( + ClusterRecoveryPointTypeApplicationConsistent ClusterRecoveryPointType = "ApplicationConsistent" + ClusterRecoveryPointTypeCrashConsistent ClusterRecoveryPointType = "CrashConsistent" + ClusterRecoveryPointTypeNotSpecified ClusterRecoveryPointType = "NotSpecified" +) + +func PossibleValuesForClusterRecoveryPointType() []string { + return []string{ + string(ClusterRecoveryPointTypeApplicationConsistent), + string(ClusterRecoveryPointTypeCrashConsistent), + string(ClusterRecoveryPointTypeNotSpecified), + } +} + +func (s *ClusterRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterRecoveryPointType(input string) (*ClusterRecoveryPointType, error) { + vals := map[string]ClusterRecoveryPointType{ + "applicationconsistent": ClusterRecoveryPointTypeApplicationConsistent, + "crashconsistent": ClusterRecoveryPointTypeCrashConsistent, + "notspecified": ClusterRecoveryPointTypeNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterRecoveryPointType(input) + return &out, nil +} + +type RecoveryPointSyncType string + +const ( + RecoveryPointSyncTypeMultiVMSyncRecoveryPoint RecoveryPointSyncType = "MultiVmSyncRecoveryPoint" +) + +func PossibleValuesForRecoveryPointSyncType() []string { + return []string{ + string(RecoveryPointSyncTypeMultiVMSyncRecoveryPoint), + } +} + +func (s *RecoveryPointSyncType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPointSyncType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPointSyncType(input string) (*RecoveryPointSyncType, error) { + vals := map[string]RecoveryPointSyncType{ + "multivmsyncrecoverypoint": RecoveryPointSyncTypeMultiVMSyncRecoveryPoint, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointSyncType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/id_replicationprotectioncluster.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/id_replicationprotectioncluster.go new file mode 100644 index 00000000000..7e5b399bbfb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/id_replicationprotectioncluster.go @@ -0,0 +1,157 @@ +package clusterrecoverypoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectionClusterId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionClusterId{} + +// ReplicationProtectionClusterId is a struct representing the Resource ID for a Replication Protection Cluster +type ReplicationProtectionClusterId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectionClusterName string +} + +// NewReplicationProtectionClusterID returns a new ReplicationProtectionClusterId struct +func NewReplicationProtectionClusterID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectionClusterName string) ReplicationProtectionClusterId { + return ReplicationProtectionClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectionClusterName: replicationProtectionClusterName, + } +} + +// ParseReplicationProtectionClusterID parses 'input' into a ReplicationProtectionClusterId +func ParseReplicationProtectionClusterID(input string) (*ReplicationProtectionClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionClusterIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionClusterId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionClusterIDInsensitively(input string) (*ReplicationProtectionClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionClusterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectionClusterName, ok = input.Parsed["replicationProtectionClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionClusterName", input) + } + + return nil +} + +// ValidateReplicationProtectionClusterID checks that 'input' can be parsed as a Replication Protection Cluster ID +func ValidateReplicationProtectionClusterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectionClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Cluster ID +func (id ReplicationProtectionClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectionClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectionClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Cluster ID +func (id ReplicationProtectionClusterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectionClusters", "replicationProtectionClusters", "replicationProtectionClusters"), + resourceids.UserSpecifiedSegment("replicationProtectionClusterName", "replicationProtectionClusterName"), + } +} + +// String returns a human-readable description of this Replication Protection Cluster ID +func (id ReplicationProtectionClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protection Cluster Name: %q", id.ReplicationProtectionClusterName), + } + return fmt.Sprintf("Replication Protection Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/id_replicationprotectioncluster_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/id_replicationprotectioncluster_test.go new file mode 100644 index 00000000000..37dd3a94fa4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/id_replicationprotectioncluster_test.go @@ -0,0 +1,417 @@ +package clusterrecoverypoints + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectionClusterId{} + +func TestNewReplicationProtectionClusterID(t *testing.T) { + id := NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectionClusterName != "replicationProtectionClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionClusterName'", id.ReplicationProtectionClusterName, "replicationProtectionClusterName") + } +} + +func TestFormatReplicationProtectionClusterID(t *testing.T) { + actual := NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName", + Expected: &ReplicationProtectionClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionClusterName: "replicationProtectionClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionClusterName != v.Expected.ReplicationProtectionClusterName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionClusterName", v.Expected.ReplicationProtectionClusterName, actual.ReplicationProtectionClusterName) + } + + } +} + +func TestParseReplicationProtectionClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName", + Expected: &ReplicationProtectionClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionClusterName: "replicationProtectionClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE", + Expected: &ReplicationProtectionClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectionClusterName: "rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionClusterName != v.Expected.ReplicationProtectionClusterName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionClusterName", v.Expected.ReplicationProtectionClusterName, actual.ReplicationProtectionClusterName) + } + + } +} + +func TestSegmentsForReplicationProtectionClusterId(t *testing.T) { + segments := ReplicationProtectionClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionClusterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/method_listbyreplicationprotectioncluster.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/method_listbyreplicationprotectioncluster.go new file mode 100644 index 00000000000..57582dc9c9d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/method_listbyreplicationprotectioncluster.go @@ -0,0 +1,105 @@ +package clusterrecoverypoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationProtectionClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ClusterRecoveryPoint +} + +type ListByReplicationProtectionClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []ClusterRecoveryPoint +} + +type ListByReplicationProtectionClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectionClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectionCluster ... +func (c ClusterRecoveryPointsClient) ListByReplicationProtectionCluster(ctx context.Context, id ReplicationProtectionClusterId) (result ListByReplicationProtectionClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationProtectionClusterCustomPager{}, + Path: fmt.Sprintf("%s/recoveryPoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ClusterRecoveryPoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionClusterComplete retrieves all the results into a single object +func (c ClusterRecoveryPointsClient) ListByReplicationProtectionClusterComplete(ctx context.Context, id ReplicationProtectionClusterId) (ListByReplicationProtectionClusterCompleteResult, error) { + return c.ListByReplicationProtectionClusterCompleteMatchingPredicate(ctx, id, ClusterRecoveryPointOperationPredicate{}) +} + +// ListByReplicationProtectionClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ClusterRecoveryPointsClient) ListByReplicationProtectionClusterCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionClusterId, predicate ClusterRecoveryPointOperationPredicate) (result ListByReplicationProtectionClusterCompleteResult, err error) { + items := make([]ClusterRecoveryPoint, 0) + + resp, err := c.ListByReplicationProtectionCluster(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 = ListByReplicationProtectionClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/model_a2aclusterrecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/model_a2aclusterrecoverypointdetails.go new file mode 100644 index 00000000000..4769a41a9ed --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/model_a2aclusterrecoverypointdetails.go @@ -0,0 +1,51 @@ +package clusterrecoverypoints + +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 _ ClusterProviderSpecificRecoveryPointDetails = A2AClusterRecoveryPointDetails{} + +type A2AClusterRecoveryPointDetails struct { + Nodes *[]string `json:"nodes,omitempty"` + RecoveryPointSyncType *RecoveryPointSyncType `json:"recoveryPointSyncType,omitempty"` + + // Fields inherited from ClusterProviderSpecificRecoveryPointDetails + + InstanceType string `json:"instanceType"` +} + +func (s A2AClusterRecoveryPointDetails) ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl { + return BaseClusterProviderSpecificRecoveryPointDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AClusterRecoveryPointDetails{} + +func (s A2AClusterRecoveryPointDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AClusterRecoveryPointDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AClusterRecoveryPointDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AClusterRecoveryPointDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AClusterRecoveryPointDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/model_clusterproviderspecificrecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/model_clusterproviderspecificrecoverypointdetails.go new file mode 100644 index 00000000000..2187d2eaceb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/model_clusterproviderspecificrecoverypointdetails.go @@ -0,0 +1,75 @@ +package clusterrecoverypoints + +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 ClusterProviderSpecificRecoveryPointDetails interface { + ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl +} + +var _ ClusterProviderSpecificRecoveryPointDetails = BaseClusterProviderSpecificRecoveryPointDetailsImpl{} + +type BaseClusterProviderSpecificRecoveryPointDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseClusterProviderSpecificRecoveryPointDetailsImpl) ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl { + return s +} + +var _ ClusterProviderSpecificRecoveryPointDetails = RawClusterProviderSpecificRecoveryPointDetailsImpl{} + +// RawClusterProviderSpecificRecoveryPointDetailsImpl 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 RawClusterProviderSpecificRecoveryPointDetailsImpl struct { + clusterProviderSpecificRecoveryPointDetails BaseClusterProviderSpecificRecoveryPointDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawClusterProviderSpecificRecoveryPointDetailsImpl) ClusterProviderSpecificRecoveryPointDetails() BaseClusterProviderSpecificRecoveryPointDetailsImpl { + return s.clusterProviderSpecificRecoveryPointDetails +} + +func UnmarshalClusterProviderSpecificRecoveryPointDetailsImplementation(input []byte) (ClusterProviderSpecificRecoveryPointDetails, 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 ClusterProviderSpecificRecoveryPointDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AClusterRecoveryPointDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AClusterRecoveryPointDetails: %+v", err) + } + return out, nil + } + + var parent BaseClusterProviderSpecificRecoveryPointDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseClusterProviderSpecificRecoveryPointDetailsImpl: %+v", err) + } + + return RawClusterProviderSpecificRecoveryPointDetailsImpl{ + clusterProviderSpecificRecoveryPointDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/model_clusterrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/model_clusterrecoverypoint.go new file mode 100644 index 00000000000..9790bb86a63 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/model_clusterrecoverypoint.go @@ -0,0 +1,11 @@ +package clusterrecoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterRecoveryPoint struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ClusterRecoveryPointProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/model_clusterrecoverypointproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/model_clusterrecoverypointproperties.go new file mode 100644 index 00000000000..46ff451b24e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/model_clusterrecoverypointproperties.go @@ -0,0 +1,60 @@ +package clusterrecoverypoints + +import ( + "encoding/json" + "fmt" + "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 ClusterRecoveryPointProperties struct { + ProviderSpecificDetails ClusterProviderSpecificRecoveryPointDetails `json:"providerSpecificDetails"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *ClusterRecoveryPointType `json:"recoveryPointType,omitempty"` +} + +func (o *ClusterRecoveryPointProperties) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ClusterRecoveryPointProperties) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} + +var _ json.Unmarshaler = &ClusterRecoveryPointProperties{} + +func (s *ClusterRecoveryPointProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *ClusterRecoveryPointType `json:"recoveryPointType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.RecoveryPointTime = decoded.RecoveryPointTime + s.RecoveryPointType = decoded.RecoveryPointType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ClusterRecoveryPointProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalClusterProviderSpecificRecoveryPointDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ClusterRecoveryPointProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/predicates.go new file mode 100644 index 00000000000..acad5aeb606 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/predicates.go @@ -0,0 +1,27 @@ +package clusterrecoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterRecoveryPointOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ClusterRecoveryPointOperationPredicate) Matches(input ClusterRecoveryPoint) 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/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/version.go new file mode 100644 index 00000000000..809a3c2287a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/clusterrecoverypoints/version.go @@ -0,0 +1,10 @@ +package clusterrecoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/clusterrecoverypoints/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/README.md new file mode 100644 index 00000000000..c6ddecee0ca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints` Documentation + +The `migrationrecoverypoints` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints" +``` + + +### Client Initialization + +```go +client := migrationrecoverypoints.NewMigrationRecoveryPointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MigrationRecoveryPointsClient.Get` + +```go +ctx := context.TODO() +id := migrationrecoverypoints.NewMigrationRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName", "migrationRecoveryPointName") + +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: `MigrationRecoveryPointsClient.ListByReplicationMigrationItems` + +```go +ctx := context.TODO() +id := migrationrecoverypoints.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +// alternatively `client.ListByReplicationMigrationItems(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationMigrationItemsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/client.go new file mode 100644 index 00000000000..a3234bd3411 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/client.go @@ -0,0 +1,26 @@ +package migrationrecoverypoints + +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 MigrationRecoveryPointsClient struct { + Client *resourcemanager.Client +} + +func NewMigrationRecoveryPointsClientWithBaseURI(sdkApi sdkEnv.Api) (*MigrationRecoveryPointsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "migrationrecoverypoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MigrationRecoveryPointsClient: %+v", err) + } + + return &MigrationRecoveryPointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/constants.go new file mode 100644 index 00000000000..a4169de2a21 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/constants.go @@ -0,0 +1,54 @@ +package migrationrecoverypoints + +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 MigrationRecoveryPointType string + +const ( + MigrationRecoveryPointTypeApplicationConsistent MigrationRecoveryPointType = "ApplicationConsistent" + MigrationRecoveryPointTypeCrashConsistent MigrationRecoveryPointType = "CrashConsistent" + MigrationRecoveryPointTypeNotSpecified MigrationRecoveryPointType = "NotSpecified" +) + +func PossibleValuesForMigrationRecoveryPointType() []string { + return []string{ + string(MigrationRecoveryPointTypeApplicationConsistent), + string(MigrationRecoveryPointTypeCrashConsistent), + string(MigrationRecoveryPointTypeNotSpecified), + } +} + +func (s *MigrationRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationRecoveryPointType(input string) (*MigrationRecoveryPointType, error) { + vals := map[string]MigrationRecoveryPointType{ + "applicationconsistent": MigrationRecoveryPointTypeApplicationConsistent, + "crashconsistent": MigrationRecoveryPointTypeCrashConsistent, + "notspecified": MigrationRecoveryPointTypeNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationRecoveryPointType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/id_migrationrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/id_migrationrecoverypoint.go new file mode 100644 index 00000000000..f0e9101261c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/id_migrationrecoverypoint.go @@ -0,0 +1,166 @@ +package migrationrecoverypoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MigrationRecoveryPointId{}) +} + +var _ resourceids.ResourceId = &MigrationRecoveryPointId{} + +// MigrationRecoveryPointId is a struct representing the Resource ID for a Migration Recovery Point +type MigrationRecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationMigrationItemName string + MigrationRecoveryPointName string +} + +// NewMigrationRecoveryPointID returns a new MigrationRecoveryPointId struct +func NewMigrationRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationMigrationItemName string, migrationRecoveryPointName string) MigrationRecoveryPointId { + return MigrationRecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationMigrationItemName: replicationMigrationItemName, + MigrationRecoveryPointName: migrationRecoveryPointName, + } +} + +// ParseMigrationRecoveryPointID parses 'input' into a MigrationRecoveryPointId +func ParseMigrationRecoveryPointID(input string) (*MigrationRecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&MigrationRecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MigrationRecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMigrationRecoveryPointIDInsensitively parses 'input' case-insensitively into a MigrationRecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseMigrationRecoveryPointIDInsensitively(input string) (*MigrationRecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&MigrationRecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MigrationRecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MigrationRecoveryPointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationMigrationItemName, ok = input.Parsed["replicationMigrationItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationMigrationItemName", input) + } + + if id.MigrationRecoveryPointName, ok = input.Parsed["migrationRecoveryPointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "migrationRecoveryPointName", input) + } + + return nil +} + +// ValidateMigrationRecoveryPointID checks that 'input' can be parsed as a Migration Recovery Point ID +func ValidateMigrationRecoveryPointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseMigrationRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Migration Recovery Point ID +func (id MigrationRecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationMigrationItems/%s/migrationRecoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationMigrationItemName, id.MigrationRecoveryPointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Migration Recovery Point ID +func (id MigrationRecoveryPointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationMigrationItems", "replicationMigrationItems", "replicationMigrationItems"), + resourceids.UserSpecifiedSegment("replicationMigrationItemName", "replicationMigrationItemName"), + resourceids.StaticSegment("staticMigrationRecoveryPoints", "migrationRecoveryPoints", "migrationRecoveryPoints"), + resourceids.UserSpecifiedSegment("migrationRecoveryPointName", "migrationRecoveryPointName"), + } +} + +// String returns a human-readable description of this Migration Recovery Point ID +func (id MigrationRecoveryPointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Migration Item Name: %q", id.ReplicationMigrationItemName), + fmt.Sprintf("Migration Recovery Point Name: %q", id.MigrationRecoveryPointName), + } + return fmt.Sprintf("Migration Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/id_migrationrecoverypoint_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/id_migrationrecoverypoint_test.go new file mode 100644 index 00000000000..d216774042c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/id_migrationrecoverypoint_test.go @@ -0,0 +1,462 @@ +package migrationrecoverypoints + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MigrationRecoveryPointId{} + +func TestNewMigrationRecoveryPointID(t *testing.T) { + id := NewMigrationRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName", "migrationRecoveryPointName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationMigrationItemName != "replicationMigrationItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationMigrationItemName'", id.ReplicationMigrationItemName, "replicationMigrationItemName") + } + + if id.MigrationRecoveryPointName != "migrationRecoveryPointName" { + t.Fatalf("Expected %q but got %q for Segment 'MigrationRecoveryPointName'", id.MigrationRecoveryPointName, "migrationRecoveryPointName") + } +} + +func TestFormatMigrationRecoveryPointID(t *testing.T) { + actual := NewMigrationRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName", "migrationRecoveryPointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/migrationRecoveryPoints/migrationRecoveryPointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMigrationRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MigrationRecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/migrationRecoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/migrationRecoveryPoints/migrationRecoveryPointName", + Expected: &MigrationRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationMigrationItemName: "replicationMigrationItemName", + MigrationRecoveryPointName: "migrationRecoveryPointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/migrationRecoveryPoints/migrationRecoveryPointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMigrationRecoveryPointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + if actual.MigrationRecoveryPointName != v.Expected.MigrationRecoveryPointName { + t.Fatalf("Expected %q but got %q for MigrationRecoveryPointName", v.Expected.MigrationRecoveryPointName, actual.MigrationRecoveryPointName) + } + + } +} + +func TestParseMigrationRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MigrationRecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/migrationRecoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE/mIgRaTiOnReCoVeRyPoInTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/migrationRecoveryPoints/migrationRecoveryPointName", + Expected: &MigrationRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationMigrationItemName: "replicationMigrationItemName", + MigrationRecoveryPointName: "migrationRecoveryPointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/migrationRecoveryPoints/migrationRecoveryPointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE/mIgRaTiOnReCoVeRyPoInTs/mIgRaTiOnReCoVeRyPoInTnAmE", + Expected: &MigrationRecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationMigrationItemName: "rEpLiCaTiOnMiGrAtIoNiTeMnAmE", + MigrationRecoveryPointName: "mIgRaTiOnReCoVeRyPoInTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE/mIgRaTiOnReCoVeRyPoInTs/mIgRaTiOnReCoVeRyPoInTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMigrationRecoveryPointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + if actual.MigrationRecoveryPointName != v.Expected.MigrationRecoveryPointName { + t.Fatalf("Expected %q but got %q for MigrationRecoveryPointName", v.Expected.MigrationRecoveryPointName, actual.MigrationRecoveryPointName) + } + + } +} + +func TestSegmentsForMigrationRecoveryPointId(t *testing.T) { + segments := MigrationRecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MigrationRecoveryPointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/id_replicationmigrationitem.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/id_replicationmigrationitem.go new file mode 100644 index 00000000000..9ccb9efa50b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/id_replicationmigrationitem.go @@ -0,0 +1,157 @@ +package migrationrecoverypoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationMigrationItemId{}) +} + +var _ resourceids.ResourceId = &ReplicationMigrationItemId{} + +// ReplicationMigrationItemId is a struct representing the Resource ID for a Replication Migration Item +type ReplicationMigrationItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationMigrationItemName string +} + +// NewReplicationMigrationItemID returns a new ReplicationMigrationItemId struct +func NewReplicationMigrationItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationMigrationItemName string) ReplicationMigrationItemId { + return ReplicationMigrationItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationMigrationItemName: replicationMigrationItemName, + } +} + +// ParseReplicationMigrationItemID parses 'input' into a ReplicationMigrationItemId +func ParseReplicationMigrationItemID(input string) (*ReplicationMigrationItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationMigrationItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationMigrationItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationMigrationItemIDInsensitively parses 'input' case-insensitively into a ReplicationMigrationItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationMigrationItemIDInsensitively(input string) (*ReplicationMigrationItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationMigrationItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationMigrationItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationMigrationItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationMigrationItemName, ok = input.Parsed["replicationMigrationItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationMigrationItemName", input) + } + + return nil +} + +// ValidateReplicationMigrationItemID checks that 'input' can be parsed as a Replication Migration Item ID +func ValidateReplicationMigrationItemID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationMigrationItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Migration Item ID +func (id ReplicationMigrationItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationMigrationItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationMigrationItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Migration Item ID +func (id ReplicationMigrationItemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationMigrationItems", "replicationMigrationItems", "replicationMigrationItems"), + resourceids.UserSpecifiedSegment("replicationMigrationItemName", "replicationMigrationItemName"), + } +} + +// String returns a human-readable description of this Replication Migration Item ID +func (id ReplicationMigrationItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Migration Item Name: %q", id.ReplicationMigrationItemName), + } + return fmt.Sprintf("Replication Migration Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/id_replicationmigrationitem_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/id_replicationmigrationitem_test.go new file mode 100644 index 00000000000..dde2cd4e339 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/id_replicationmigrationitem_test.go @@ -0,0 +1,417 @@ +package migrationrecoverypoints + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationMigrationItemId{} + +func TestNewReplicationMigrationItemID(t *testing.T) { + id := NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationMigrationItemName != "replicationMigrationItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationMigrationItemName'", id.ReplicationMigrationItemName, "replicationMigrationItemName") + } +} + +func TestFormatReplicationMigrationItemID(t *testing.T) { + actual := NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationMigrationItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationMigrationItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationMigrationItemName: "replicationMigrationItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationMigrationItemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + } +} + +func TestParseReplicationMigrationItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationMigrationItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationMigrationItemName: "replicationMigrationItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationMigrationItemName: "rEpLiCaTiOnMiGrAtIoNiTeMnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationMigrationItemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + } +} + +func TestSegmentsForReplicationMigrationItemId(t *testing.T) { + segments := ReplicationMigrationItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationMigrationItemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/method_get.go new file mode 100644 index 00000000000..dc4d09d6440 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/method_get.go @@ -0,0 +1,53 @@ +package migrationrecoverypoints + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *MigrationRecoveryPoint +} + +// Get ... +func (c MigrationRecoveryPointsClient) Get(ctx context.Context, id MigrationRecoveryPointId) (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 MigrationRecoveryPoint + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/method_listbyreplicationmigrationitems.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/method_listbyreplicationmigrationitems.go new file mode 100644 index 00000000000..a850052471e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/method_listbyreplicationmigrationitems.go @@ -0,0 +1,105 @@ +package migrationrecoverypoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationMigrationItemsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MigrationRecoveryPoint +} + +type ListByReplicationMigrationItemsCompleteResult struct { + LatestHttpResponse *http.Response + Items []MigrationRecoveryPoint +} + +type ListByReplicationMigrationItemsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationMigrationItemsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationMigrationItems ... +func (c MigrationRecoveryPointsClient) ListByReplicationMigrationItems(ctx context.Context, id ReplicationMigrationItemId) (result ListByReplicationMigrationItemsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationMigrationItemsCustomPager{}, + Path: fmt.Sprintf("%s/migrationRecoveryPoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MigrationRecoveryPoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationMigrationItemsComplete retrieves all the results into a single object +func (c MigrationRecoveryPointsClient) ListByReplicationMigrationItemsComplete(ctx context.Context, id ReplicationMigrationItemId) (ListByReplicationMigrationItemsCompleteResult, error) { + return c.ListByReplicationMigrationItemsCompleteMatchingPredicate(ctx, id, MigrationRecoveryPointOperationPredicate{}) +} + +// ListByReplicationMigrationItemsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MigrationRecoveryPointsClient) ListByReplicationMigrationItemsCompleteMatchingPredicate(ctx context.Context, id ReplicationMigrationItemId, predicate MigrationRecoveryPointOperationPredicate) (result ListByReplicationMigrationItemsCompleteResult, err error) { + items := make([]MigrationRecoveryPoint, 0) + + resp, err := c.ListByReplicationMigrationItems(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 = ListByReplicationMigrationItemsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/model_migrationrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/model_migrationrecoverypoint.go new file mode 100644 index 00000000000..6b0ba9fb2d1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/model_migrationrecoverypoint.go @@ -0,0 +1,12 @@ +package migrationrecoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationRecoveryPoint struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MigrationRecoveryPointProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/model_migrationrecoverypointproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/model_migrationrecoverypointproperties.go new file mode 100644 index 00000000000..65f481c3cb9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/model_migrationrecoverypointproperties.go @@ -0,0 +1,27 @@ +package migrationrecoverypoints + +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 MigrationRecoveryPointProperties struct { + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *MigrationRecoveryPointType `json:"recoveryPointType,omitempty"` +} + +func (o *MigrationRecoveryPointProperties) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MigrationRecoveryPointProperties) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/predicates.go new file mode 100644 index 00000000000..62a451ad032 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/predicates.go @@ -0,0 +1,32 @@ +package migrationrecoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationRecoveryPointOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p MigrationRecoveryPointOperationPredicate) Matches(input MigrationRecoveryPoint) 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/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/version.go new file mode 100644 index 00000000000..0aade12abeb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/migrationrecoverypoints/version.go @@ -0,0 +1,10 @@ +package migrationrecoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/migrationrecoverypoints/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/README.md new file mode 100644 index 00000000000..8442ec2e4af --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/README.md @@ -0,0 +1,38 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/operations` Documentation + +The `operations` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/operations" +``` + + +### Client Initialization + +```go +client := operations.NewOperationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OperationsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/client.go new file mode 100644 index 00000000000..5afee8af6f7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/client.go @@ -0,0 +1,26 @@ +package operations + +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 OperationsClient struct { + Client *resourcemanager.Client +} + +func NewOperationsClientWithBaseURI(sdkApi sdkEnv.Api) (*OperationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "operations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OperationsClient: %+v", err) + } + + return &OperationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/method_list.go new file mode 100644 index 00000000000..b83b36e2e63 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/method_list.go @@ -0,0 +1,106 @@ +package operations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]OperationsDiscovery +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []OperationsDiscovery +} + +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 OperationsClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.RecoveryServices/operations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]OperationsDiscovery `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 OperationsClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, OperationsDiscoveryOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c OperationsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate OperationsDiscoveryOperationPredicate) (result ListCompleteResult, err error) { + items := make([]OperationsDiscovery, 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/recoveryservicessiterecovery/2025-02-01/operations/model_display.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/model_display.go new file mode 100644 index 00000000000..9b13c14d48d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/model_display.go @@ -0,0 +1,11 @@ +package operations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Display struct { + Description *string `json:"description,omitempty"` + Operation *string `json:"operation,omitempty"` + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/model_operationsdiscovery.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/model_operationsdiscovery.go new file mode 100644 index 00000000000..fbd67f9e9f4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/model_operationsdiscovery.go @@ -0,0 +1,11 @@ +package operations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OperationsDiscovery struct { + Display *Display `json:"display,omitempty"` + Name *string `json:"name,omitempty"` + Origin *string `json:"origin,omitempty"` + Properties *interface{} `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/predicates.go new file mode 100644 index 00000000000..6c9c733282f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/predicates.go @@ -0,0 +1,27 @@ +package operations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OperationsDiscoveryOperationPredicate struct { + Name *string + Origin *string + Properties *interface{} +} + +func (p OperationsDiscoveryOperationPredicate) Matches(input OperationsDiscovery) bool { + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Origin != nil && (input.Origin == nil || *p.Origin != *input.Origin) { + return false + } + + if p.Properties != nil && (input.Properties == nil || *p.Properties != *input.Properties) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/version.go new file mode 100644 index 00000000000..0fc2fae54e8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/operations/version.go @@ -0,0 +1,10 @@ +package operations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/operations/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/README.md new file mode 100644 index 00000000000..d174c99d0d7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints` Documentation + +The `recoverypoints` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/recoverypoints" +``` + + +### Client Initialization + +```go +client := recoverypoints.NewRecoveryPointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecoveryPointsClient.Get` + +```go +ctx := context.TODO() +id := recoverypoints.NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName", "recoveryPointName") + +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: `RecoveryPointsClient.ListByReplicationProtectedItems` + +```go +ctx := context.TODO() +id := recoverypoints.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +// alternatively `client.ListByReplicationProtectedItems(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectedItemsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/client.go new file mode 100644 index 00000000000..56e764beced --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/client.go @@ -0,0 +1,26 @@ +package recoverypoints + +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 RecoveryPointsClient struct { + Client *resourcemanager.Client +} + +func NewRecoveryPointsClientWithBaseURI(sdkApi sdkEnv.Api) (*RecoveryPointsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "recoverypoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RecoveryPointsClient: %+v", err) + } + + return &RecoveryPointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/constants.go new file mode 100644 index 00000000000..db07d9b75c9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/constants.go @@ -0,0 +1,51 @@ +package recoverypoints + +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 RecoveryPointSyncType string + +const ( + RecoveryPointSyncTypeMultiVMSyncRecoveryPoint RecoveryPointSyncType = "MultiVmSyncRecoveryPoint" + RecoveryPointSyncTypePerVMRecoveryPoint RecoveryPointSyncType = "PerVmRecoveryPoint" +) + +func PossibleValuesForRecoveryPointSyncType() []string { + return []string{ + string(RecoveryPointSyncTypeMultiVMSyncRecoveryPoint), + string(RecoveryPointSyncTypePerVMRecoveryPoint), + } +} + +func (s *RecoveryPointSyncType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPointSyncType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPointSyncType(input string) (*RecoveryPointSyncType, error) { + vals := map[string]RecoveryPointSyncType{ + "multivmsyncrecoverypoint": RecoveryPointSyncTypeMultiVMSyncRecoveryPoint, + "pervmrecoverypoint": RecoveryPointSyncTypePerVMRecoveryPoint, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointSyncType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/id_recoverypoint.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/id_recoverypoint.go new file mode 100644 index 00000000000..961edec2d6d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/id_recoverypoint.go @@ -0,0 +1,166 @@ +package recoverypoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RecoveryPointId{}) +} + +var _ resourceids.ResourceId = &RecoveryPointId{} + +// RecoveryPointId is a struct representing the Resource ID for a Recovery Point +type RecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectedItemName string + RecoveryPointName string +} + +// NewRecoveryPointID returns a new RecoveryPointId struct +func NewRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectedItemName string, recoveryPointName string) RecoveryPointId { + return RecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectedItemName: replicationProtectedItemName, + RecoveryPointName: recoveryPointName, + } +} + +// ParseRecoveryPointID parses 'input' into a RecoveryPointId +func ParseRecoveryPointID(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRecoveryPointIDInsensitively parses 'input' case-insensitively into a RecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseRecoveryPointIDInsensitively(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RecoveryPointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectedItemName, ok = input.Parsed["replicationProtectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectedItemName", input) + } + + if id.RecoveryPointName, ok = input.Parsed["recoveryPointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recoveryPointName", input) + } + + return nil +} + +// ValidateRecoveryPointID checks that 'input' can be parsed as a Recovery Point ID +func ValidateRecoveryPointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Recovery Point ID +func (id RecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectedItems/%s/recoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectedItemName, id.RecoveryPointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Recovery Point ID +func (id RecoveryPointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectedItems", "replicationProtectedItems", "replicationProtectedItems"), + resourceids.UserSpecifiedSegment("replicationProtectedItemName", "replicationProtectedItemName"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointName", "recoveryPointName"), + } +} + +// String returns a human-readable description of this Recovery Point ID +func (id RecoveryPointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protected Item Name: %q", id.ReplicationProtectedItemName), + fmt.Sprintf("Recovery Point Name: %q", id.RecoveryPointName), + } + return fmt.Sprintf("Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/id_recoverypoint_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/id_recoverypoint_test.go new file mode 100644 index 00000000000..f7195561c72 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/id_recoverypoint_test.go @@ -0,0 +1,462 @@ +package recoverypoints + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RecoveryPointId{} + +func TestNewRecoveryPointID(t *testing.T) { + id := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName", "recoveryPointName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectedItemName != "replicationProtectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectedItemName'", id.ReplicationProtectedItemName, "replicationProtectedItemName") + } + + if id.RecoveryPointName != "recoveryPointName" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointName'", id.RecoveryPointName, "recoveryPointName") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName", "recoveryPointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/recoveryPoints/recoveryPointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/recoveryPoints/recoveryPointName", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + RecoveryPointName: "recoveryPointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/recoveryPoints/recoveryPointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + if actual.RecoveryPointName != v.Expected.RecoveryPointName { + t.Fatalf("Expected %q but got %q for RecoveryPointName", v.Expected.RecoveryPointName, actual.RecoveryPointName) + } + + } +} + +func TestParseRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/recoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/recoveryPoints/recoveryPointName", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + RecoveryPointName: "recoveryPointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/recoveryPoints/recoveryPointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE/rEcOvErYpOiNtS/rEcOvErYpOiNtNaMe", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectedItemName: "rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + RecoveryPointName: "rEcOvErYpOiNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE/rEcOvErYpOiNtS/rEcOvErYpOiNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + if actual.RecoveryPointName != v.Expected.RecoveryPointName { + t.Fatalf("Expected %q but got %q for RecoveryPointName", v.Expected.RecoveryPointName, actual.RecoveryPointName) + } + + } +} + +func TestSegmentsForRecoveryPointId(t *testing.T) { + segments := RecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RecoveryPointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/id_replicationprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/id_replicationprotecteditem.go new file mode 100644 index 00000000000..6c0d7acae11 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/id_replicationprotecteditem.go @@ -0,0 +1,157 @@ +package recoverypoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectedItemId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectedItemId{} + +// ReplicationProtectedItemId is a struct representing the Resource ID for a Replication Protected Item +type ReplicationProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectedItemName string +} + +// NewReplicationProtectedItemID returns a new ReplicationProtectedItemId struct +func NewReplicationProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectedItemName string) ReplicationProtectedItemId { + return ReplicationProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectedItemName: replicationProtectedItemName, + } +} + +// ParseReplicationProtectedItemID parses 'input' into a ReplicationProtectedItemId +func ParseReplicationProtectedItemID(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectedItemIDInsensitively parses 'input' case-insensitively into a ReplicationProtectedItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectedItemIDInsensitively(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectedItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectedItemName, ok = input.Parsed["replicationProtectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectedItemName", input) + } + + return nil +} + +// ValidateReplicationProtectedItemID checks that 'input' can be parsed as a Replication Protected Item ID +func ValidateReplicationProtectedItemID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectedItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protected Item ID +func (id ReplicationProtectedItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectedItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectedItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protected Item ID +func (id ReplicationProtectedItemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectedItems", "replicationProtectedItems", "replicationProtectedItems"), + resourceids.UserSpecifiedSegment("replicationProtectedItemName", "replicationProtectedItemName"), + } +} + +// String returns a human-readable description of this Replication Protected Item ID +func (id ReplicationProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protected Item Name: %q", id.ReplicationProtectedItemName), + } + return fmt.Sprintf("Replication Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/id_replicationprotecteditem_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/id_replicationprotecteditem_test.go new file mode 100644 index 00000000000..f60a0f6a4a3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/id_replicationprotecteditem_test.go @@ -0,0 +1,417 @@ +package recoverypoints + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectedItemId{} + +func TestNewReplicationProtectedItemID(t *testing.T) { + id := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectedItemName != "replicationProtectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectedItemName'", id.ReplicationProtectedItemName, "replicationProtectedItemName") + } +} + +func TestFormatReplicationProtectedItemID(t *testing.T) { + actual := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestParseReplicationProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectedItemName: "rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestSegmentsForReplicationProtectedItemId(t *testing.T) { + segments := ReplicationProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectedItemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/method_get.go new file mode 100644 index 00000000000..843b463fac6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/method_get.go @@ -0,0 +1,53 @@ +package recoverypoints + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *RecoveryPoint +} + +// Get ... +func (c RecoveryPointsClient) Get(ctx context.Context, id RecoveryPointId) (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 RecoveryPoint + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/method_listbyreplicationprotecteditems.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/method_listbyreplicationprotecteditems.go new file mode 100644 index 00000000000..dd0de009d18 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/method_listbyreplicationprotecteditems.go @@ -0,0 +1,105 @@ +package recoverypoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationProtectedItemsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RecoveryPoint +} + +type ListByReplicationProtectedItemsCompleteResult struct { + LatestHttpResponse *http.Response + Items []RecoveryPoint +} + +type ListByReplicationProtectedItemsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectedItemsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectedItems ... +func (c RecoveryPointsClient) ListByReplicationProtectedItems(ctx context.Context, id ReplicationProtectedItemId) (result ListByReplicationProtectedItemsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationProtectedItemsCustomPager{}, + Path: fmt.Sprintf("%s/recoveryPoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RecoveryPoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectedItemsComplete retrieves all the results into a single object +func (c RecoveryPointsClient) ListByReplicationProtectedItemsComplete(ctx context.Context, id ReplicationProtectedItemId) (ListByReplicationProtectedItemsCompleteResult, error) { + return c.ListByReplicationProtectedItemsCompleteMatchingPredicate(ctx, id, RecoveryPointOperationPredicate{}) +} + +// ListByReplicationProtectedItemsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecoveryPointsClient) ListByReplicationProtectedItemsCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectedItemId, predicate RecoveryPointOperationPredicate) (result ListByReplicationProtectedItemsCompleteResult, err error) { + items := make([]RecoveryPoint, 0) + + resp, err := c.ListByReplicationProtectedItems(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 = ListByReplicationProtectedItemsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_a2arecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_a2arecoverypointdetails.go new file mode 100644 index 00000000000..339b8f2d0a7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_a2arecoverypointdetails.go @@ -0,0 +1,51 @@ +package recoverypoints + +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 _ ProviderSpecificRecoveryPointDetails = A2ARecoveryPointDetails{} + +type A2ARecoveryPointDetails struct { + Disks *[]string `json:"disks,omitempty"` + RecoveryPointSyncType *RecoveryPointSyncType `json:"recoveryPointSyncType,omitempty"` + + // Fields inherited from ProviderSpecificRecoveryPointDetails + + InstanceType string `json:"instanceType"` +} + +func (s A2ARecoveryPointDetails) ProviderSpecificRecoveryPointDetails() BaseProviderSpecificRecoveryPointDetailsImpl { + return BaseProviderSpecificRecoveryPointDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ARecoveryPointDetails{} + +func (s A2ARecoveryPointDetails) MarshalJSON() ([]byte, error) { + type wrapper A2ARecoveryPointDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ARecoveryPointDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ARecoveryPointDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ARecoveryPointDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_inmageazurev2recoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_inmageazurev2recoverypointdetails.go new file mode 100644 index 00000000000..d97d0651905 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_inmageazurev2recoverypointdetails.go @@ -0,0 +1,50 @@ +package recoverypoints + +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 _ ProviderSpecificRecoveryPointDetails = InMageAzureV2RecoveryPointDetails{} + +type InMageAzureV2RecoveryPointDetails struct { + IsMultiVMSyncPoint *string `json:"isMultiVmSyncPoint,omitempty"` + + // Fields inherited from ProviderSpecificRecoveryPointDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2RecoveryPointDetails) ProviderSpecificRecoveryPointDetails() BaseProviderSpecificRecoveryPointDetailsImpl { + return BaseProviderSpecificRecoveryPointDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2RecoveryPointDetails{} + +func (s InMageAzureV2RecoveryPointDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2RecoveryPointDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2RecoveryPointDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2RecoveryPointDetails: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2RecoveryPointDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_inmagercmrecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_inmagercmrecoverypointdetails.go new file mode 100644 index 00000000000..f0dcc4811be --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_inmagercmrecoverypointdetails.go @@ -0,0 +1,50 @@ +package recoverypoints + +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 _ ProviderSpecificRecoveryPointDetails = InMageRcmRecoveryPointDetails{} + +type InMageRcmRecoveryPointDetails struct { + IsMultiVMSyncPoint *string `json:"isMultiVmSyncPoint,omitempty"` + + // Fields inherited from ProviderSpecificRecoveryPointDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmRecoveryPointDetails) ProviderSpecificRecoveryPointDetails() BaseProviderSpecificRecoveryPointDetailsImpl { + return BaseProviderSpecificRecoveryPointDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmRecoveryPointDetails{} + +func (s InMageRcmRecoveryPointDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmRecoveryPointDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmRecoveryPointDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmRecoveryPointDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmRecoveryPointDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_providerspecificrecoverypointdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_providerspecificrecoverypointdetails.go new file mode 100644 index 00000000000..8ba70b192af --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_providerspecificrecoverypointdetails.go @@ -0,0 +1,91 @@ +package recoverypoints + +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 ProviderSpecificRecoveryPointDetails interface { + ProviderSpecificRecoveryPointDetails() BaseProviderSpecificRecoveryPointDetailsImpl +} + +var _ ProviderSpecificRecoveryPointDetails = BaseProviderSpecificRecoveryPointDetailsImpl{} + +type BaseProviderSpecificRecoveryPointDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseProviderSpecificRecoveryPointDetailsImpl) ProviderSpecificRecoveryPointDetails() BaseProviderSpecificRecoveryPointDetailsImpl { + return s +} + +var _ ProviderSpecificRecoveryPointDetails = RawProviderSpecificRecoveryPointDetailsImpl{} + +// RawProviderSpecificRecoveryPointDetailsImpl 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 RawProviderSpecificRecoveryPointDetailsImpl struct { + providerSpecificRecoveryPointDetails BaseProviderSpecificRecoveryPointDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawProviderSpecificRecoveryPointDetailsImpl) ProviderSpecificRecoveryPointDetails() BaseProviderSpecificRecoveryPointDetailsImpl { + return s.providerSpecificRecoveryPointDetails +} + +func UnmarshalProviderSpecificRecoveryPointDetailsImplementation(input []byte) (ProviderSpecificRecoveryPointDetails, 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 ProviderSpecificRecoveryPointDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2ARecoveryPointDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ARecoveryPointDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2RecoveryPointDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2RecoveryPointDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmRecoveryPointDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmRecoveryPointDetails: %+v", err) + } + return out, nil + } + + var parent BaseProviderSpecificRecoveryPointDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProviderSpecificRecoveryPointDetailsImpl: %+v", err) + } + + return RawProviderSpecificRecoveryPointDetailsImpl{ + providerSpecificRecoveryPointDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_recoverypoint.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_recoverypoint.go new file mode 100644 index 00000000000..cd0df01a0a3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_recoverypoint.go @@ -0,0 +1,12 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPoint struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecoveryPointProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_recoverypointproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_recoverypointproperties.go new file mode 100644 index 00000000000..c993201bfb7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/model_recoverypointproperties.go @@ -0,0 +1,60 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" + "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 RecoveryPointProperties struct { + ProviderSpecificDetails ProviderSpecificRecoveryPointDetails `json:"providerSpecificDetails"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` +} + +func (o *RecoveryPointProperties) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPointProperties) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} + +var _ json.Unmarshaler = &RecoveryPointProperties{} + +func (s *RecoveryPointProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.RecoveryPointTime = decoded.RecoveryPointTime + s.RecoveryPointType = decoded.RecoveryPointType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPointProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalProviderSpecificRecoveryPointDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'RecoveryPointProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/predicates.go new file mode 100644 index 00000000000..599a0311cbf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/predicates.go @@ -0,0 +1,32 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RecoveryPointOperationPredicate) Matches(input RecoveryPoint) 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/recoveryservicessiterecovery/2025-02-01/recoverypoints/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/version.go new file mode 100644 index 00000000000..119f93e344c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/recoverypoints/version.go @@ -0,0 +1,10 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/recoverypoints/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/README.md new file mode 100644 index 00000000000..bbe9b25b219 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/README.md @@ -0,0 +1,74 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings` Documentation + +The `replicationalertsettings` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationalertsettings" +``` + + +### Client Initialization + +```go +client := replicationalertsettings.NewReplicationAlertSettingsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationAlertSettingsClient.Create` + +```go +ctx := context.TODO() +id := replicationalertsettings.NewReplicationAlertSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationAlertSettingName") + +payload := replicationalertsettings.ConfigureAlertRequest{ + // ... +} + + +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: `ReplicationAlertSettingsClient.Get` + +```go +ctx := context.TODO() +id := replicationalertsettings.NewReplicationAlertSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationAlertSettingName") + +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: `ReplicationAlertSettingsClient.List` + +```go +ctx := context.TODO() +id := replicationalertsettings.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/client.go new file mode 100644 index 00000000000..6150bc2ecfa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/client.go @@ -0,0 +1,26 @@ +package replicationalertsettings + +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 ReplicationAlertSettingsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationAlertSettingsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationAlertSettingsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationalertsettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationAlertSettingsClient: %+v", err) + } + + return &ReplicationAlertSettingsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/id_replicationalertsetting.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/id_replicationalertsetting.go new file mode 100644 index 00000000000..58cedfe08d3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/id_replicationalertsetting.go @@ -0,0 +1,139 @@ +package replicationalertsettings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationAlertSettingId{}) +} + +var _ resourceids.ResourceId = &ReplicationAlertSettingId{} + +// ReplicationAlertSettingId is a struct representing the Resource ID for a Replication Alert Setting +type ReplicationAlertSettingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationAlertSettingName string +} + +// NewReplicationAlertSettingID returns a new ReplicationAlertSettingId struct +func NewReplicationAlertSettingID(subscriptionId string, resourceGroupName string, vaultName string, replicationAlertSettingName string) ReplicationAlertSettingId { + return ReplicationAlertSettingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationAlertSettingName: replicationAlertSettingName, + } +} + +// ParseReplicationAlertSettingID parses 'input' into a ReplicationAlertSettingId +func ParseReplicationAlertSettingID(input string) (*ReplicationAlertSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationAlertSettingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationAlertSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationAlertSettingIDInsensitively parses 'input' case-insensitively into a ReplicationAlertSettingId +// note: this method should only be used for API response data and not user input +func ParseReplicationAlertSettingIDInsensitively(input string) (*ReplicationAlertSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationAlertSettingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationAlertSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationAlertSettingId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationAlertSettingName, ok = input.Parsed["replicationAlertSettingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationAlertSettingName", input) + } + + return nil +} + +// ValidateReplicationAlertSettingID checks that 'input' can be parsed as a Replication Alert Setting ID +func ValidateReplicationAlertSettingID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationAlertSettingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Alert Setting ID +func (id ReplicationAlertSettingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationAlertSettings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationAlertSettingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Alert Setting ID +func (id ReplicationAlertSettingId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationAlertSettings", "replicationAlertSettings", "replicationAlertSettings"), + resourceids.UserSpecifiedSegment("replicationAlertSettingName", "replicationAlertSettingName"), + } +} + +// String returns a human-readable description of this Replication Alert Setting ID +func (id ReplicationAlertSettingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Alert Setting Name: %q", id.ReplicationAlertSettingName), + } + return fmt.Sprintf("Replication Alert Setting (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/id_replicationalertsetting_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/id_replicationalertsetting_test.go new file mode 100644 index 00000000000..56e5094c009 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/id_replicationalertsetting_test.go @@ -0,0 +1,327 @@ +package replicationalertsettings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationAlertSettingId{} + +func TestNewReplicationAlertSettingID(t *testing.T) { + id := NewReplicationAlertSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationAlertSettingName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationAlertSettingName != "replicationAlertSettingName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationAlertSettingName'", id.ReplicationAlertSettingName, "replicationAlertSettingName") + } +} + +func TestFormatReplicationAlertSettingID(t *testing.T) { + actual := NewReplicationAlertSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationAlertSettingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationAlertSettings/replicationAlertSettingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationAlertSettingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationAlertSettingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationAlertSettings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationAlertSettings/replicationAlertSettingName", + Expected: &ReplicationAlertSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationAlertSettingName: "replicationAlertSettingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationAlertSettings/replicationAlertSettingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationAlertSettingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationAlertSettingName != v.Expected.ReplicationAlertSettingName { + t.Fatalf("Expected %q but got %q for ReplicationAlertSettingName", v.Expected.ReplicationAlertSettingName, actual.ReplicationAlertSettingName) + } + + } +} + +func TestParseReplicationAlertSettingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationAlertSettingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationAlertSettings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnAlErTsEtTiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationAlertSettings/replicationAlertSettingName", + Expected: &ReplicationAlertSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationAlertSettingName: "replicationAlertSettingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationAlertSettings/replicationAlertSettingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnAlErTsEtTiNgS/rEpLiCaTiOnAlErTsEtTiNgNaMe", + Expected: &ReplicationAlertSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationAlertSettingName: "rEpLiCaTiOnAlErTsEtTiNgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnAlErTsEtTiNgS/rEpLiCaTiOnAlErTsEtTiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationAlertSettingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationAlertSettingName != v.Expected.ReplicationAlertSettingName { + t.Fatalf("Expected %q but got %q for ReplicationAlertSettingName", v.Expected.ReplicationAlertSettingName, actual.ReplicationAlertSettingName) + } + + } +} + +func TestSegmentsForReplicationAlertSettingId(t *testing.T) { + segments := ReplicationAlertSettingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationAlertSettingId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/id_vault.go new file mode 100644 index 00000000000..4d0e369d238 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/id_vault.go @@ -0,0 +1,130 @@ +package replicationalertsettings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/id_vault_test.go new file mode 100644 index 00000000000..9d66b7eb7e7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationalertsettings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/method_create.go new file mode 100644 index 00000000000..8f2a9586892 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/method_create.go @@ -0,0 +1,57 @@ +package replicationalertsettings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Alert +} + +// Create ... +func (c ReplicationAlertSettingsClient) Create(ctx context.Context, id ReplicationAlertSettingId, input ConfigureAlertRequest) (result CreateOperationResponse, 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 Alert + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/method_get.go new file mode 100644 index 00000000000..78834c0d17f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/method_get.go @@ -0,0 +1,53 @@ +package replicationalertsettings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Alert +} + +// Get ... +func (c ReplicationAlertSettingsClient) Get(ctx context.Context, id ReplicationAlertSettingId) (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 Alert + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/method_list.go new file mode 100644 index 00000000000..3d9e40c5690 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/method_list.go @@ -0,0 +1,105 @@ +package replicationalertsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]Alert +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Alert +} + +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 ReplicationAlertSettingsClient) List(ctx context.Context, id VaultId) (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/replicationAlertSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Alert `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 ReplicationAlertSettingsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AlertOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationAlertSettingsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate AlertOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Alert, 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/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/model_alert.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/model_alert.go new file mode 100644 index 00000000000..003e317d3b9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/model_alert.go @@ -0,0 +1,12 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Alert struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AlertProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/model_alertproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/model_alertproperties.go new file mode 100644 index 00000000000..470729facab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/model_alertproperties.go @@ -0,0 +1,10 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AlertProperties struct { + CustomEmailAddresses *[]string `json:"customEmailAddresses,omitempty"` + Locale *string `json:"locale,omitempty"` + SendToOwners *string `json:"sendToOwners,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/model_configurealertrequest.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/model_configurealertrequest.go new file mode 100644 index 00000000000..b914ebe04a9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/model_configurealertrequest.go @@ -0,0 +1,8 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigureAlertRequest struct { + Properties *ConfigureAlertRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/model_configurealertrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/model_configurealertrequestproperties.go new file mode 100644 index 00000000000..d5a6752d183 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/model_configurealertrequestproperties.go @@ -0,0 +1,10 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigureAlertRequestProperties struct { + CustomEmailAddresses *[]string `json:"customEmailAddresses,omitempty"` + Locale *string `json:"locale,omitempty"` + SendToOwners *string `json:"sendToOwners,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/predicates.go new file mode 100644 index 00000000000..456cd1b810e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/predicates.go @@ -0,0 +1,32 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AlertOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AlertOperationPredicate) Matches(input Alert) 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/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/version.go new file mode 100644 index 00000000000..095ebbf3670 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationalertsettings/version.go @@ -0,0 +1,10 @@ +package replicationalertsettings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationalertsettings/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/README.md new file mode 100644 index 00000000000..efd6859bdb8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances` Documentation + +The `replicationappliances` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationappliances" +``` + + +### Client Initialization + +```go +client := replicationappliances.NewReplicationAppliancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationAppliancesClient.List` + +```go +ctx := context.TODO() +id := replicationappliances.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, replicationappliances.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationappliances.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/client.go new file mode 100644 index 00000000000..6a851868099 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/client.go @@ -0,0 +1,26 @@ +package replicationappliances + +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 ReplicationAppliancesClient struct { + Client *resourcemanager.Client +} + +func NewReplicationAppliancesClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationAppliancesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationappliances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationAppliancesClient: %+v", err) + } + + return &ReplicationAppliancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/constants.go new file mode 100644 index 00000000000..55e598cf7dc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/constants.go @@ -0,0 +1,145 @@ +package replicationappliances + +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 HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type ProtectionHealth string + +const ( + ProtectionHealthCritical ProtectionHealth = "Critical" + ProtectionHealthNone ProtectionHealth = "None" + ProtectionHealthNormal ProtectionHealth = "Normal" + ProtectionHealthWarning ProtectionHealth = "Warning" +) + +func PossibleValuesForProtectionHealth() []string { + return []string{ + string(ProtectionHealthCritical), + string(ProtectionHealthNone), + string(ProtectionHealthNormal), + string(ProtectionHealthWarning), + } +} + +func (s *ProtectionHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtectionHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtectionHealth(input string) (*ProtectionHealth, error) { + vals := map[string]ProtectionHealth{ + "critical": ProtectionHealthCritical, + "none": ProtectionHealthNone, + "normal": ProtectionHealthNormal, + "warning": ProtectionHealthWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionHealth(input) + return &out, nil +} + +type RcmComponentStatus string + +const ( + RcmComponentStatusCritical RcmComponentStatus = "Critical" + RcmComponentStatusHealthy RcmComponentStatus = "Healthy" + RcmComponentStatusUnknown RcmComponentStatus = "Unknown" + RcmComponentStatusWarning RcmComponentStatus = "Warning" +) + +func PossibleValuesForRcmComponentStatus() []string { + return []string{ + string(RcmComponentStatusCritical), + string(RcmComponentStatusHealthy), + string(RcmComponentStatusUnknown), + string(RcmComponentStatusWarning), + } +} + +func (s *RcmComponentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRcmComponentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRcmComponentStatus(input string) (*RcmComponentStatus, error) { + vals := map[string]RcmComponentStatus{ + "critical": RcmComponentStatusCritical, + "healthy": RcmComponentStatusHealthy, + "unknown": RcmComponentStatusUnknown, + "warning": RcmComponentStatusWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RcmComponentStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/id_vault.go new file mode 100644 index 00000000000..840bc253579 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/id_vault.go @@ -0,0 +1,130 @@ +package replicationappliances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/id_vault_test.go new file mode 100644 index 00000000000..b55e9882b37 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationappliances + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/method_list.go new file mode 100644 index 00000000000..a8a0449c5c0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/method_list.go @@ -0,0 +1,134 @@ +package replicationappliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ReplicationAppliance +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationAppliance +} + +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 ReplicationAppliancesClient) List(ctx context.Context, id VaultId, 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/replicationAppliances", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReplicationAppliance `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 ReplicationAppliancesClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ReplicationApplianceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationAppliancesClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ReplicationApplianceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ReplicationAppliance, 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/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_appliancespecificdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_appliancespecificdetails.go new file mode 100644 index 00000000000..e74fab76d77 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_appliancespecificdetails.go @@ -0,0 +1,75 @@ +package replicationappliances + +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 ApplianceSpecificDetails interface { + ApplianceSpecificDetails() BaseApplianceSpecificDetailsImpl +} + +var _ ApplianceSpecificDetails = BaseApplianceSpecificDetailsImpl{} + +type BaseApplianceSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseApplianceSpecificDetailsImpl) ApplianceSpecificDetails() BaseApplianceSpecificDetailsImpl { + return s +} + +var _ ApplianceSpecificDetails = RawApplianceSpecificDetailsImpl{} + +// RawApplianceSpecificDetailsImpl 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 RawApplianceSpecificDetailsImpl struct { + applianceSpecificDetails BaseApplianceSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawApplianceSpecificDetailsImpl) ApplianceSpecificDetails() BaseApplianceSpecificDetailsImpl { + return s.applianceSpecificDetails +} + +func UnmarshalApplianceSpecificDetailsImplementation(input []byte) (ApplianceSpecificDetails, 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 ApplianceSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmApplianceSpecificDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmApplianceSpecificDetails: %+v", err) + } + return out, nil + } + + var parent BaseApplianceSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseApplianceSpecificDetailsImpl: %+v", err) + } + + return RawApplianceSpecificDetailsImpl{ + applianceSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_dradetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_dradetails.go new file mode 100644 index 00000000000..fcde153537f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_dradetails.go @@ -0,0 +1,34 @@ +package replicationappliances + +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 DraDetails struct { + BiosId *string `json:"biosId,omitempty"` + ForwardProtectedItemCount *int64 `json:"forwardProtectedItemCount,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + ReverseProtectedItemCount *int64 `json:"reverseProtectedItemCount,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *DraDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *DraDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_healtherror.go new file mode 100644 index 00000000000..1780f919219 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationappliances + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_inmagercmappliancedetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_inmagercmappliancedetails.go new file mode 100644 index 00000000000..df2d5e14881 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_inmagercmappliancedetails.go @@ -0,0 +1,18 @@ +package replicationappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmApplianceDetails struct { + Dra *DraDetails `json:"dra,omitempty"` + FabricArmId *string `json:"fabricArmId,omitempty"` + Id *string `json:"id,omitempty"` + MarsAgent *MarsAgentDetails `json:"marsAgent,omitempty"` + Name *string `json:"name,omitempty"` + ProcessServer *ProcessServerDetails `json:"processServer,omitempty"` + PushInstaller *PushInstallerDetails `json:"pushInstaller,omitempty"` + RcmProxy *RcmProxyDetails `json:"rcmProxy,omitempty"` + ReplicationAgent *ReplicationAgentDetails `json:"replicationAgent,omitempty"` + ReprotectAgent *ReprotectAgentDetails `json:"reprotectAgent,omitempty"` + SwitchProviderBlockingErrorDetails *[]InMageRcmFabricSwitchProviderBlockingErrorDetails `json:"switchProviderBlockingErrorDetails,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_inmagercmappliancespecificdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_inmagercmappliancespecificdetails.go new file mode 100644 index 00000000000..1dc38a9db93 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_inmagercmappliancespecificdetails.go @@ -0,0 +1,50 @@ +package replicationappliances + +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 _ ApplianceSpecificDetails = InMageRcmApplianceSpecificDetails{} + +type InMageRcmApplianceSpecificDetails struct { + Appliances *[]InMageRcmApplianceDetails `json:"appliances,omitempty"` + + // Fields inherited from ApplianceSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmApplianceSpecificDetails) ApplianceSpecificDetails() BaseApplianceSpecificDetailsImpl { + return BaseApplianceSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmApplianceSpecificDetails{} + +func (s InMageRcmApplianceSpecificDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmApplianceSpecificDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmApplianceSpecificDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmApplianceSpecificDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmApplianceSpecificDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_inmagercmfabricswitchproviderblockingerrordetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_inmagercmfabricswitchproviderblockingerrordetails.go new file mode 100644 index 00000000000..84a5830cb6b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_inmagercmfabricswitchproviderblockingerrordetails.go @@ -0,0 +1,13 @@ +package replicationappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmFabricSwitchProviderBlockingErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_innerhealtherror.go new file mode 100644 index 00000000000..76f31c711be --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationappliances + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_marsagentdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_marsagentdetails.go new file mode 100644 index 00000000000..edf0158b990 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_marsagentdetails.go @@ -0,0 +1,34 @@ +package replicationappliances + +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 MarsAgentDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *MarsAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *MarsAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_processserverdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_processserverdetails.go new file mode 100644 index 00000000000..43de3ca2697 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_processserverdetails.go @@ -0,0 +1,54 @@ +package replicationappliances + +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 ProcessServerDetails struct { + AvailableMemoryInBytes *int64 `json:"availableMemoryInBytes,omitempty"` + AvailableSpaceInBytes *int64 `json:"availableSpaceInBytes,omitempty"` + BiosId *string `json:"biosId,omitempty"` + DiskUsageStatus *RcmComponentStatus `json:"diskUsageStatus,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + FreeSpacePercentage *float64 `json:"freeSpacePercentage,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + HistoricHealth *ProtectionHealth `json:"historicHealth,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + MemoryUsagePercentage *float64 `json:"memoryUsagePercentage,omitempty"` + MemoryUsageStatus *RcmComponentStatus `json:"memoryUsageStatus,omitempty"` + Name *string `json:"name,omitempty"` + ProcessorUsagePercentage *float64 `json:"processorUsagePercentage,omitempty"` + ProcessorUsageStatus *RcmComponentStatus `json:"processorUsageStatus,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + SystemLoad *int64 `json:"systemLoad,omitempty"` + SystemLoadStatus *RcmComponentStatus `json:"systemLoadStatus,omitempty"` + ThroughputInBytes *int64 `json:"throughputInBytes,omitempty"` + ThroughputStatus *RcmComponentStatus `json:"throughputStatus,omitempty"` + ThroughputUploadPendingDataInBytes *int64 `json:"throughputUploadPendingDataInBytes,omitempty"` + TotalMemoryInBytes *int64 `json:"totalMemoryInBytes,omitempty"` + TotalSpaceInBytes *int64 `json:"totalSpaceInBytes,omitempty"` + UsedMemoryInBytes *int64 `json:"usedMemoryInBytes,omitempty"` + UsedSpaceInBytes *int64 `json:"usedSpaceInBytes,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ProcessServerDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServerDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_pushinstallerdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_pushinstallerdetails.go new file mode 100644 index 00000000000..485a5173ab5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_pushinstallerdetails.go @@ -0,0 +1,34 @@ +package replicationappliances + +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 PushInstallerDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *PushInstallerDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *PushInstallerDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_rcmproxydetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_rcmproxydetails.go new file mode 100644 index 00000000000..1d29ef4a653 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_rcmproxydetails.go @@ -0,0 +1,35 @@ +package replicationappliances + +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 RcmProxyDetails struct { + BiosId *string `json:"biosId,omitempty"` + ClientAuthenticationType *string `json:"clientAuthenticationType,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *RcmProxyDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *RcmProxyDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_replicationagentdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_replicationagentdetails.go new file mode 100644 index 00000000000..5147a2d9142 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_replicationagentdetails.go @@ -0,0 +1,34 @@ +package replicationappliances + +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 ReplicationAgentDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ReplicationAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_replicationappliance.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_replicationappliance.go new file mode 100644 index 00000000000..65955cd695d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_replicationappliance.go @@ -0,0 +1,8 @@ +package replicationappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationAppliance struct { + Properties *ReplicationApplianceProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_replicationapplianceproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_replicationapplianceproperties.go new file mode 100644 index 00000000000..73f48639767 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_replicationapplianceproperties.go @@ -0,0 +1,33 @@ +package replicationappliances + +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 ReplicationApplianceProperties struct { + ProviderSpecificDetails ApplianceSpecificDetails `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ReplicationApplianceProperties{} + +func (s *ReplicationApplianceProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ReplicationApplianceProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalApplianceSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ReplicationApplianceProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_reprotectagentdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_reprotectagentdetails.go new file mode 100644 index 00000000000..da40fca482c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/model_reprotectagentdetails.go @@ -0,0 +1,50 @@ +package replicationappliances + +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 ReprotectAgentDetails struct { + AccessibleDatastores *[]string `json:"accessibleDatastores,omitempty"` + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastDiscoveryInUtc *string `json:"lastDiscoveryInUtc,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + VcenterId *string `json:"vcenterId,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ReprotectAgentDetails) GetLastDiscoveryInUtcAsTime() (*time.Time, error) { + if o.LastDiscoveryInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastDiscoveryInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReprotectAgentDetails) SetLastDiscoveryInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastDiscoveryInUtc = &formatted +} + +func (o *ReprotectAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReprotectAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/predicates.go new file mode 100644 index 00000000000..58258537c8d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/predicates.go @@ -0,0 +1,12 @@ +package replicationappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationApplianceOperationPredicate struct { +} + +func (p ReplicationApplianceOperationPredicate) Matches(input ReplicationAppliance) bool { + + return true +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/version.go new file mode 100644 index 00000000000..a8fd0b50882 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationappliances/version.go @@ -0,0 +1,10 @@ +package replicationappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationappliances/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/README.md new file mode 100644 index 00000000000..27e9f1ea74a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/README.md @@ -0,0 +1,52 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults` Documentation + +The `replicationeligibilityresults` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults" +``` + + +### Client Initialization + +```go +client := replicationeligibilityresults.NewReplicationEligibilityResultsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationEligibilityResultsClient.Get` + +```go +ctx := context.TODO() +id := replicationeligibilityresults.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + +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: `ReplicationEligibilityResultsClient.List` + +```go +ctx := context.TODO() +id := replicationeligibilityresults.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineName") + +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/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/client.go new file mode 100644 index 00000000000..329a008dd1f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/client.go @@ -0,0 +1,26 @@ +package replicationeligibilityresults + +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 ReplicationEligibilityResultsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationEligibilityResultsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationEligibilityResultsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationeligibilityresults", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationEligibilityResultsClient: %+v", err) + } + + return &ReplicationEligibilityResultsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/id_virtualmachine.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/id_virtualmachine.go new file mode 100644 index 00000000000..bd0dca13f94 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/id_virtualmachine.go @@ -0,0 +1,130 @@ +package replicationeligibilityresults + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) 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.Compute/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("staticMicrosoftCompute", "Microsoft.Compute", "Microsoft.Compute"), + 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/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/id_virtualmachine_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/id_virtualmachine_test.go new file mode 100644 index 00000000000..2c4a1ce212a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/id_virtualmachine_test.go @@ -0,0 +1,282 @@ +package replicationeligibilityresults + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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.Compute/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.Compute", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/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.Compute/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.Compute", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachines", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/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.Compute/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.cOmPuTe/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.cOmPuTe/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/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/method_get.go new file mode 100644 index 00000000000..b2c86ad7756 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/method_get.go @@ -0,0 +1,54 @@ +package replicationeligibilityresults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ReplicationEligibilityResults +} + +// Get ... +func (c ReplicationEligibilityResultsClient) Get(ctx context.Context, id VirtualMachineId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.RecoveryServices/replicationEligibilityResults/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 ReplicationEligibilityResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/method_list.go new file mode 100644 index 00000000000..5547cd4b49f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/method_list.go @@ -0,0 +1,54 @@ +package replicationeligibilityresults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ReplicationEligibilityResultsCollection +} + +// List ... +func (c ReplicationEligibilityResultsClient) List(ctx context.Context, id VirtualMachineId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.RecoveryServices/replicationEligibilityResults", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ReplicationEligibilityResultsCollection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/model_replicationeligibilityresults.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/model_replicationeligibilityresults.go new file mode 100644 index 00000000000..c14c19713c9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/model_replicationeligibilityresults.go @@ -0,0 +1,11 @@ +package replicationeligibilityresults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationEligibilityResults struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReplicationEligibilityResultsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/model_replicationeligibilityresultscollection.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/model_replicationeligibilityresultscollection.go new file mode 100644 index 00000000000..2dc729eb1ca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/model_replicationeligibilityresultscollection.go @@ -0,0 +1,8 @@ +package replicationeligibilityresults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationEligibilityResultsCollection struct { + Value *[]ReplicationEligibilityResults `json:"value,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/model_replicationeligibilityresultserrorinfo.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/model_replicationeligibilityresultserrorinfo.go new file mode 100644 index 00000000000..a81d7856188 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/model_replicationeligibilityresultserrorinfo.go @@ -0,0 +1,12 @@ +package replicationeligibilityresults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationEligibilityResultsErrorInfo struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/model_replicationeligibilityresultsproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/model_replicationeligibilityresultsproperties.go new file mode 100644 index 00000000000..ebc67f22629 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/model_replicationeligibilityresultsproperties.go @@ -0,0 +1,9 @@ +package replicationeligibilityresults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationEligibilityResultsProperties struct { + ClientRequestId *string `json:"clientRequestId,omitempty"` + Errors *[]ReplicationEligibilityResultsErrorInfo `json:"errors,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/version.go new file mode 100644 index 00000000000..0434073290b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationeligibilityresults/version.go @@ -0,0 +1,10 @@ +package replicationeligibilityresults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationeligibilityresults/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/README.md new file mode 100644 index 00000000000..aee6179b29a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents` Documentation + +The `replicationevents` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationevents" +``` + + +### Client Initialization + +```go +client := replicationevents.NewReplicationEventsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationEventsClient.Get` + +```go +ctx := context.TODO() +id := replicationevents.NewReplicationEventID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationEventName") + +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: `ReplicationEventsClient.List` + +```go +ctx := context.TODO() +id := replicationevents.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, replicationevents.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationevents.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/client.go new file mode 100644 index 00000000000..65b05326a32 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/client.go @@ -0,0 +1,26 @@ +package replicationevents + +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 ReplicationEventsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationEventsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationEventsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationevents", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationEventsClient: %+v", err) + } + + return &ReplicationEventsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/constants.go new file mode 100644 index 00000000000..209501caff5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/constants.go @@ -0,0 +1,51 @@ +package replicationevents + +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 HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/id_replicationevent.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/id_replicationevent.go new file mode 100644 index 00000000000..9a94a8d463c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/id_replicationevent.go @@ -0,0 +1,139 @@ +package replicationevents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationEventId{}) +} + +var _ resourceids.ResourceId = &ReplicationEventId{} + +// ReplicationEventId is a struct representing the Resource ID for a Replication Event +type ReplicationEventId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationEventName string +} + +// NewReplicationEventID returns a new ReplicationEventId struct +func NewReplicationEventID(subscriptionId string, resourceGroupName string, vaultName string, replicationEventName string) ReplicationEventId { + return ReplicationEventId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationEventName: replicationEventName, + } +} + +// ParseReplicationEventID parses 'input' into a ReplicationEventId +func ParseReplicationEventID(input string) (*ReplicationEventId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationEventId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationEventId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationEventIDInsensitively parses 'input' case-insensitively into a ReplicationEventId +// note: this method should only be used for API response data and not user input +func ParseReplicationEventIDInsensitively(input string) (*ReplicationEventId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationEventId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationEventId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationEventId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationEventName, ok = input.Parsed["replicationEventName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationEventName", input) + } + + return nil +} + +// ValidateReplicationEventID checks that 'input' can be parsed as a Replication Event ID +func ValidateReplicationEventID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationEventID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Event ID +func (id ReplicationEventId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationEvents/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationEventName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Event ID +func (id ReplicationEventId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationEvents", "replicationEvents", "replicationEvents"), + resourceids.UserSpecifiedSegment("replicationEventName", "replicationEventName"), + } +} + +// String returns a human-readable description of this Replication Event ID +func (id ReplicationEventId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Event Name: %q", id.ReplicationEventName), + } + return fmt.Sprintf("Replication Event (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/id_replicationevent_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/id_replicationevent_test.go new file mode 100644 index 00000000000..f4be6ef83fd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/id_replicationevent_test.go @@ -0,0 +1,327 @@ +package replicationevents + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationEventId{} + +func TestNewReplicationEventID(t *testing.T) { + id := NewReplicationEventID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationEventName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationEventName != "replicationEventName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationEventName'", id.ReplicationEventName, "replicationEventName") + } +} + +func TestFormatReplicationEventID(t *testing.T) { + actual := NewReplicationEventID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationEventName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationEvents/replicationEventName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationEventID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationEventId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationEvents", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationEvents/replicationEventName", + Expected: &ReplicationEventId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationEventName: "replicationEventName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationEvents/replicationEventName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationEventID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationEventName != v.Expected.ReplicationEventName { + t.Fatalf("Expected %q but got %q for ReplicationEventName", v.Expected.ReplicationEventName, actual.ReplicationEventName) + } + + } +} + +func TestParseReplicationEventIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationEventId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationEvents", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnEvEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationEvents/replicationEventName", + Expected: &ReplicationEventId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationEventName: "replicationEventName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationEvents/replicationEventName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnEvEnTs/rEpLiCaTiOnEvEnTnAmE", + Expected: &ReplicationEventId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationEventName: "rEpLiCaTiOnEvEnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnEvEnTs/rEpLiCaTiOnEvEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationEventIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationEventName != v.Expected.ReplicationEventName { + t.Fatalf("Expected %q but got %q for ReplicationEventName", v.Expected.ReplicationEventName, actual.ReplicationEventName) + } + + } +} + +func TestSegmentsForReplicationEventId(t *testing.T) { + segments := ReplicationEventId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationEventId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/id_vault.go new file mode 100644 index 00000000000..f540d5ea573 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/id_vault.go @@ -0,0 +1,130 @@ +package replicationevents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/id_vault_test.go new file mode 100644 index 00000000000..fc824ae5e8b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationevents + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/method_get.go new file mode 100644 index 00000000000..c04ce4fb4ea --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/method_get.go @@ -0,0 +1,53 @@ +package replicationevents + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Event +} + +// Get ... +func (c ReplicationEventsClient) Get(ctx context.Context, id ReplicationEventId) (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 Event + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/method_list.go new file mode 100644 index 00000000000..d53ecc1e068 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/method_list.go @@ -0,0 +1,134 @@ +package replicationevents + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]Event +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Event +} + +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 ReplicationEventsClient) List(ctx context.Context, id VaultId, 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/replicationEvents", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Event `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 ReplicationEventsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, EventOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationEventsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate EventOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Event, 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/recoveryservicessiterecovery/2025-02-01/replicationevents/model_a2aeventdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_a2aeventdetails.go new file mode 100644 index 00000000000..1fdd6f86eef --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_a2aeventdetails.go @@ -0,0 +1,55 @@ +package replicationevents + +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 _ EventProviderSpecificDetails = A2AEventDetails{} + +type A2AEventDetails struct { + FabricLocation *string `json:"fabricLocation,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + ProtectedItemName *string `json:"protectedItemName,omitempty"` + RemoteFabricLocation *string `json:"remoteFabricLocation,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s A2AEventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AEventDetails{} + +func (s A2AEventDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AEventDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_event.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_event.go new file mode 100644 index 00000000000..e80daa64ebb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_event.go @@ -0,0 +1,12 @@ +package replicationevents + +// 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 { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *EventProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_eventproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_eventproperties.go new file mode 100644 index 00000000000..810b6bbd324 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_eventproperties.go @@ -0,0 +1,90 @@ +package replicationevents + +import ( + "encoding/json" + "fmt" + "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 EventProperties struct { + AffectedObjectCorrelationId *string `json:"affectedObjectCorrelationId,omitempty"` + AffectedObjectFriendlyName *string `json:"affectedObjectFriendlyName,omitempty"` + Description *string `json:"description,omitempty"` + EventCode *string `json:"eventCode,omitempty"` + EventSpecificDetails EventSpecificDetails `json:"eventSpecificDetails"` + EventType *string `json:"eventType,omitempty"` + FabricId *string `json:"fabricId,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + ProviderSpecificDetails EventProviderSpecificDetails `json:"providerSpecificDetails"` + Severity *string `json:"severity,omitempty"` + TimeOfOccurrence *string `json:"timeOfOccurrence,omitempty"` +} + +func (o *EventProperties) GetTimeOfOccurrenceAsTime() (*time.Time, error) { + if o.TimeOfOccurrence == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeOfOccurrence, "2006-01-02T15:04:05Z07:00") +} + +func (o *EventProperties) SetTimeOfOccurrenceAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeOfOccurrence = &formatted +} + +var _ json.Unmarshaler = &EventProperties{} + +func (s *EventProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AffectedObjectCorrelationId *string `json:"affectedObjectCorrelationId,omitempty"` + AffectedObjectFriendlyName *string `json:"affectedObjectFriendlyName,omitempty"` + Description *string `json:"description,omitempty"` + EventCode *string `json:"eventCode,omitempty"` + EventType *string `json:"eventType,omitempty"` + FabricId *string `json:"fabricId,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Severity *string `json:"severity,omitempty"` + TimeOfOccurrence *string `json:"timeOfOccurrence,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AffectedObjectCorrelationId = decoded.AffectedObjectCorrelationId + s.AffectedObjectFriendlyName = decoded.AffectedObjectFriendlyName + s.Description = decoded.Description + s.EventCode = decoded.EventCode + s.EventType = decoded.EventType + s.FabricId = decoded.FabricId + s.HealthErrors = decoded.HealthErrors + s.Severity = decoded.Severity + s.TimeOfOccurrence = decoded.TimeOfOccurrence + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling EventProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["eventSpecificDetails"]; ok { + impl, err := UnmarshalEventSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'EventSpecificDetails' for 'EventProperties': %+v", err) + } + s.EventSpecificDetails = impl + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalEventProviderSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'EventProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_eventproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_eventproviderspecificdetails.go new file mode 100644 index 00000000000..3b7783158d5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_eventproviderspecificdetails.go @@ -0,0 +1,139 @@ +package replicationevents + +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 EventProviderSpecificDetails interface { + EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl +} + +var _ EventProviderSpecificDetails = BaseEventProviderSpecificDetailsImpl{} + +type BaseEventProviderSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseEventProviderSpecificDetailsImpl) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return s +} + +var _ EventProviderSpecificDetails = RawEventProviderSpecificDetailsImpl{} + +// RawEventProviderSpecificDetailsImpl 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 RawEventProviderSpecificDetailsImpl struct { + eventProviderSpecificDetails BaseEventProviderSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawEventProviderSpecificDetailsImpl) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return s.eventProviderSpecificDetails +} + +func UnmarshalEventProviderSpecificDetailsImplementation(input []byte) (EventProviderSpecificDetails, 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 EventProviderSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012") { + var out HyperVReplica2012EventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplica2012EventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012R2") { + var out HyperVReplica2012R2EventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplica2012R2EventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaBaseEventDetails") { + var out HyperVReplicaBaseEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBaseEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2EventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2EventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackEventDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtEventDetails: %+v", err) + } + return out, nil + } + + var parent BaseEventProviderSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseEventProviderSpecificDetailsImpl: %+v", err) + } + + return RawEventProviderSpecificDetailsImpl{ + eventProviderSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_eventspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_eventspecificdetails.go new file mode 100644 index 00000000000..12bb0a88f4e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_eventspecificdetails.go @@ -0,0 +1,75 @@ +package replicationevents + +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 EventSpecificDetails interface { + EventSpecificDetails() BaseEventSpecificDetailsImpl +} + +var _ EventSpecificDetails = BaseEventSpecificDetailsImpl{} + +type BaseEventSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseEventSpecificDetailsImpl) EventSpecificDetails() BaseEventSpecificDetailsImpl { + return s +} + +var _ EventSpecificDetails = RawEventSpecificDetailsImpl{} + +// RawEventSpecificDetailsImpl 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 RawEventSpecificDetailsImpl struct { + eventSpecificDetails BaseEventSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawEventSpecificDetailsImpl) EventSpecificDetails() BaseEventSpecificDetailsImpl { + return s.eventSpecificDetails +} + +func UnmarshalEventSpecificDetailsImplementation(input []byte) (EventSpecificDetails, 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 EventSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "JobStatus") { + var out JobStatusEventDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into JobStatusEventDetails: %+v", err) + } + return out, nil + } + + var parent BaseEventSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseEventSpecificDetailsImpl: %+v", err) + } + + return RawEventSpecificDetailsImpl{ + eventSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_healtherror.go new file mode 100644 index 00000000000..7739a4360d6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationevents + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_hypervreplica2012eventdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_hypervreplica2012eventdetails.go new file mode 100644 index 00000000000..515da58c7c4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_hypervreplica2012eventdetails.go @@ -0,0 +1,53 @@ +package replicationevents + +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 _ EventProviderSpecificDetails = HyperVReplica2012EventDetails{} + +type HyperVReplica2012EventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplica2012EventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplica2012EventDetails{} + +func (s HyperVReplica2012EventDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplica2012EventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplica2012EventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplica2012EventDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplica2012EventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_hypervreplica2012r2eventdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_hypervreplica2012r2eventdetails.go new file mode 100644 index 00000000000..9b702881f52 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_hypervreplica2012r2eventdetails.go @@ -0,0 +1,53 @@ +package replicationevents + +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 _ EventProviderSpecificDetails = HyperVReplica2012R2EventDetails{} + +type HyperVReplica2012R2EventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplica2012R2EventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplica2012R2EventDetails{} + +func (s HyperVReplica2012R2EventDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplica2012R2EventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplica2012R2EventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplica2012R2EventDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012R2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplica2012R2EventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_hypervreplicaazureeventdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_hypervreplicaazureeventdetails.go new file mode 100644 index 00000000000..116628f1e3c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_hypervreplicaazureeventdetails.go @@ -0,0 +1,52 @@ +package replicationevents + +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 _ EventProviderSpecificDetails = HyperVReplicaAzureEventDetails{} + +type HyperVReplicaAzureEventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureEventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureEventDetails{} + +func (s HyperVReplicaAzureEventDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureEventDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_hypervreplicabaseeventdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_hypervreplicabaseeventdetails.go new file mode 100644 index 00000000000..213dc282ec0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_hypervreplicabaseeventdetails.go @@ -0,0 +1,53 @@ +package replicationevents + +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 _ EventProviderSpecificDetails = HyperVReplicaBaseEventDetails{} + +type HyperVReplicaBaseEventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaBaseEventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaBaseEventDetails{} + +func (s HyperVReplicaBaseEventDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBaseEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBaseEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBaseEventDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaBaseEventDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBaseEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_inmageazurev2eventdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_inmageazurev2eventdetails.go new file mode 100644 index 00000000000..983bdac1c99 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_inmageazurev2eventdetails.go @@ -0,0 +1,56 @@ +package replicationevents + +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 _ EventProviderSpecificDetails = InMageAzureV2EventDetails{} + +type InMageAzureV2EventDetails struct { + Category *string `json:"category,omitempty"` + Component *string `json:"component,omitempty"` + CorrectiveAction *string `json:"correctiveAction,omitempty"` + Details *string `json:"details,omitempty"` + EventType *string `json:"eventType,omitempty"` + SiteName *string `json:"siteName,omitempty"` + Summary *string `json:"summary,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2EventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2EventDetails{} + +func (s InMageAzureV2EventDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2EventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2EventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2EventDetails: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2EventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_inmagercmeventdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_inmagercmeventdetails.go new file mode 100644 index 00000000000..6a9d920bb45 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_inmagercmeventdetails.go @@ -0,0 +1,57 @@ +package replicationevents + +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 _ EventProviderSpecificDetails = InMageRcmEventDetails{} + +type InMageRcmEventDetails struct { + ApplianceName *string `json:"applianceName,omitempty"` + ComponentDisplayName *string `json:"componentDisplayName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + JobId *string `json:"jobId,omitempty"` + LatestAgentVersion *string `json:"latestAgentVersion,omitempty"` + ProtectedItemName *string `json:"protectedItemName,omitempty"` + ServerType *string `json:"serverType,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmEventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmEventDetails{} + +func (s InMageRcmEventDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmEventDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_inmagercmfailbackeventdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_inmagercmfailbackeventdetails.go new file mode 100644 index 00000000000..e8a1f913af4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_inmagercmfailbackeventdetails.go @@ -0,0 +1,54 @@ +package replicationevents + +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 _ EventProviderSpecificDetails = InMageRcmFailbackEventDetails{} + +type InMageRcmFailbackEventDetails struct { + ApplianceName *string `json:"applianceName,omitempty"` + ComponentDisplayName *string `json:"componentDisplayName,omitempty"` + ProtectedItemName *string `json:"protectedItemName,omitempty"` + ServerType *string `json:"serverType,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFailbackEventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFailbackEventDetails{} + +func (s InMageRcmFailbackEventDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackEventDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_innerhealtherror.go new file mode 100644 index 00000000000..357c416c2ff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationevents + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_jobstatuseventdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_jobstatuseventdetails.go new file mode 100644 index 00000000000..4920df2048e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_jobstatuseventdetails.go @@ -0,0 +1,53 @@ +package replicationevents + +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 _ EventSpecificDetails = JobStatusEventDetails{} + +type JobStatusEventDetails struct { + AffectedObjectType *string `json:"affectedObjectType,omitempty"` + JobFriendlyName *string `json:"jobFriendlyName,omitempty"` + JobId *string `json:"jobId,omitempty"` + JobStatus *string `json:"jobStatus,omitempty"` + + // Fields inherited from EventSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s JobStatusEventDetails) EventSpecificDetails() BaseEventSpecificDetailsImpl { + return BaseEventSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = JobStatusEventDetails{} + +func (s JobStatusEventDetails) MarshalJSON() ([]byte, error) { + type wrapper JobStatusEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling JobStatusEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling JobStatusEventDetails: %+v", err) + } + + decoded["instanceType"] = "JobStatus" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling JobStatusEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_vmwarecbteventdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_vmwarecbteventdetails.go new file mode 100644 index 00000000000..410c87a3b1e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/model_vmwarecbteventdetails.go @@ -0,0 +1,50 @@ +package replicationevents + +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 _ EventProviderSpecificDetails = VMwareCbtEventDetails{} + +type VMwareCbtEventDetails struct { + MigrationItemName *string `json:"migrationItemName,omitempty"` + + // Fields inherited from EventProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtEventDetails) EventProviderSpecificDetails() BaseEventProviderSpecificDetailsImpl { + return BaseEventProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtEventDetails{} + +func (s VMwareCbtEventDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtEventDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtEventDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtEventDetails: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtEventDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/predicates.go new file mode 100644 index 00000000000..323e9dc1ff0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/predicates.go @@ -0,0 +1,32 @@ +package replicationevents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EventOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p EventOperationPredicate) Matches(input Event) 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/recoveryservicessiterecovery/2025-02-01/replicationevents/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/version.go new file mode 100644 index 00000000000..6cd3c9838f9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationevents/version.go @@ -0,0 +1,10 @@ +package replicationevents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationevents/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/README.md new file mode 100644 index 00000000000..5f59a7464c7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/README.md @@ -0,0 +1,164 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics` Documentation + +The `replicationfabrics` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationfabrics" +``` + + +### Client Initialization + +```go +client := replicationfabrics.NewReplicationFabricsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationFabricsClient.CheckConsistency` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +if err := client.CheckConsistencyThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.Create` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +payload := replicationfabrics.FabricCreationInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.Delete` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.Get` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +read, err := client.Get(ctx, id, replicationfabrics.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ReplicationFabricsClient.List` + +```go +ctx := context.TODO() +id := replicationfabrics.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// 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: `ReplicationFabricsClient.MigrateToAad` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +if err := client.MigrateToAadThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.Purge` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +if err := client.PurgeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.ReassociateGateway` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +payload := replicationfabrics.FailoverProcessServerRequest{ + // ... +} + + +if err := client.ReassociateGatewayThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.RemoveInfra` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +if err := client.RemoveInfraThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationFabricsClient.RenewCertificate` + +```go +ctx := context.TODO() +id := replicationfabrics.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +payload := replicationfabrics.RenewCertificateInput{ + // ... +} + + +if err := client.RenewCertificateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/client.go new file mode 100644 index 00000000000..70508d500a7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/client.go @@ -0,0 +1,26 @@ +package replicationfabrics + +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 ReplicationFabricsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationFabricsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationFabricsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationfabrics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationFabricsClient: %+v", err) + } + + return &ReplicationFabricsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/constants.go new file mode 100644 index 00000000000..26c8d7e1b38 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/constants.go @@ -0,0 +1,195 @@ +package replicationfabrics + +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 AgentVersionStatus string + +const ( + AgentVersionStatusDeprecated AgentVersionStatus = "Deprecated" + AgentVersionStatusNotSupported AgentVersionStatus = "NotSupported" + AgentVersionStatusSecurityUpdateRequired AgentVersionStatus = "SecurityUpdateRequired" + AgentVersionStatusSupported AgentVersionStatus = "Supported" + AgentVersionStatusUpdateRequired AgentVersionStatus = "UpdateRequired" +) + +func PossibleValuesForAgentVersionStatus() []string { + return []string{ + string(AgentVersionStatusDeprecated), + string(AgentVersionStatusNotSupported), + string(AgentVersionStatusSecurityUpdateRequired), + string(AgentVersionStatusSupported), + string(AgentVersionStatusUpdateRequired), + } +} + +func (s *AgentVersionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentVersionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentVersionStatus(input string) (*AgentVersionStatus, error) { + vals := map[string]AgentVersionStatus{ + "deprecated": AgentVersionStatusDeprecated, + "notsupported": AgentVersionStatusNotSupported, + "securityupdaterequired": AgentVersionStatusSecurityUpdateRequired, + "supported": AgentVersionStatusSupported, + "updaterequired": AgentVersionStatusUpdateRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentVersionStatus(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type ProtectionHealth string + +const ( + ProtectionHealthCritical ProtectionHealth = "Critical" + ProtectionHealthNone ProtectionHealth = "None" + ProtectionHealthNormal ProtectionHealth = "Normal" + ProtectionHealthWarning ProtectionHealth = "Warning" +) + +func PossibleValuesForProtectionHealth() []string { + return []string{ + string(ProtectionHealthCritical), + string(ProtectionHealthNone), + string(ProtectionHealthNormal), + string(ProtectionHealthWarning), + } +} + +func (s *ProtectionHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtectionHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtectionHealth(input string) (*ProtectionHealth, error) { + vals := map[string]ProtectionHealth{ + "critical": ProtectionHealthCritical, + "none": ProtectionHealthNone, + "normal": ProtectionHealthNormal, + "warning": ProtectionHealthWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionHealth(input) + return &out, nil +} + +type RcmComponentStatus string + +const ( + RcmComponentStatusCritical RcmComponentStatus = "Critical" + RcmComponentStatusHealthy RcmComponentStatus = "Healthy" + RcmComponentStatusUnknown RcmComponentStatus = "Unknown" + RcmComponentStatusWarning RcmComponentStatus = "Warning" +) + +func PossibleValuesForRcmComponentStatus() []string { + return []string{ + string(RcmComponentStatusCritical), + string(RcmComponentStatusHealthy), + string(RcmComponentStatusUnknown), + string(RcmComponentStatusWarning), + } +} + +func (s *RcmComponentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRcmComponentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRcmComponentStatus(input string) (*RcmComponentStatus, error) { + vals := map[string]RcmComponentStatus{ + "critical": RcmComponentStatusCritical, + "healthy": RcmComponentStatusHealthy, + "unknown": RcmComponentStatusUnknown, + "warning": RcmComponentStatusWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RcmComponentStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/id_replicationfabric.go new file mode 100644 index 00000000000..020505872b8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/id_replicationfabric.go @@ -0,0 +1,139 @@ +package replicationfabrics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationFabricId{}) +} + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/id_replicationfabric_test.go new file mode 100644 index 00000000000..19edc4fbec2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationfabrics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/id_vault.go new file mode 100644 index 00000000000..d5e352feba9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/id_vault.go @@ -0,0 +1,130 @@ +package replicationfabrics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/id_vault_test.go new file mode 100644 index 00000000000..a8000d12f4a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationfabrics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_checkconsistency.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_checkconsistency.go new file mode 100644 index 00000000000..36419d8f8cc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_checkconsistency.go @@ -0,0 +1,71 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckConsistencyOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Fabric +} + +// CheckConsistency ... +func (c ReplicationFabricsClient) CheckConsistency(ctx context.Context, id ReplicationFabricId) (result CheckConsistencyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkConsistency", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CheckConsistencyThenPoll performs CheckConsistency then polls until it's completed +func (c ReplicationFabricsClient) CheckConsistencyThenPoll(ctx context.Context, id ReplicationFabricId) error { + result, err := c.CheckConsistency(ctx, id) + if err != nil { + return fmt.Errorf("performing CheckConsistency: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CheckConsistency: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_create.go new file mode 100644 index 00000000000..651d923fdab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_create.go @@ -0,0 +1,75 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Fabric +} + +// Create ... +func (c ReplicationFabricsClient) Create(ctx context.Context, id ReplicationFabricId, input FabricCreationInput) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationFabricsClient) CreateThenPoll(ctx context.Context, id ReplicationFabricId, input FabricCreationInput) 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/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_delete.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_delete.go new file mode 100644 index 00000000000..2c456521a1e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_delete.go @@ -0,0 +1,70 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 ReplicationFabricsClient) Delete(ctx context.Context, id ReplicationFabricId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.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 ReplicationFabricsClient) DeleteThenPoll(ctx context.Context, id ReplicationFabricId) 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/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_get.go new file mode 100644 index 00000000000..4ddb027258c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_get.go @@ -0,0 +1,83 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Fabric +} + +type GetOperationOptions struct { + Filter *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// Get ... +func (c ReplicationFabricsClient) Get(ctx context.Context, id ReplicationFabricId, 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 Fabric + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_list.go new file mode 100644 index 00000000000..9087564b359 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_list.go @@ -0,0 +1,105 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]Fabric +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Fabric +} + +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 ReplicationFabricsClient) List(ctx context.Context, id VaultId) (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/replicationFabrics", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Fabric `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 ReplicationFabricsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, FabricOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationFabricsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate FabricOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Fabric, 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/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_migratetoaad.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_migratetoaad.go new file mode 100644 index 00000000000..b7fcaf76c6e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_migratetoaad.go @@ -0,0 +1,70 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateToAadOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// MigrateToAad ... +func (c ReplicationFabricsClient) MigrateToAad(ctx context.Context, id ReplicationFabricId) (result MigrateToAadOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migratetoaad", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// MigrateToAadThenPoll performs MigrateToAad then polls until it's completed +func (c ReplicationFabricsClient) MigrateToAadThenPoll(ctx context.Context, id ReplicationFabricId) error { + result, err := c.MigrateToAad(ctx, id) + if err != nil { + return fmt.Errorf("performing MigrateToAad: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MigrateToAad: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_purge.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_purge.go new file mode 100644 index 00000000000..23d0862e294 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_purge.go @@ -0,0 +1,70 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c ReplicationFabricsClient) Purge(ctx context.Context, id ReplicationFabricId) (result PurgeOperationResponse, 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 +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c ReplicationFabricsClient) PurgeThenPoll(ctx context.Context, id ReplicationFabricId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_reassociategateway.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_reassociategateway.go new file mode 100644 index 00000000000..94cc0eb4bae --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_reassociategateway.go @@ -0,0 +1,75 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReassociateGatewayOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Fabric +} + +// ReassociateGateway ... +func (c ReplicationFabricsClient) ReassociateGateway(ctx context.Context, id ReplicationFabricId, input FailoverProcessServerRequest) (result ReassociateGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reassociateGateway", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReassociateGatewayThenPoll performs ReassociateGateway then polls until it's completed +func (c ReplicationFabricsClient) ReassociateGatewayThenPoll(ctx context.Context, id ReplicationFabricId, input FailoverProcessServerRequest) error { + result, err := c.ReassociateGateway(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ReassociateGateway: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ReassociateGateway: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_removeinfra.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_removeinfra.go new file mode 100644 index 00000000000..242bf25cd2b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_removeinfra.go @@ -0,0 +1,69 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoveInfraOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RemoveInfra ... +func (c ReplicationFabricsClient) RemoveInfra(ctx context.Context, id ReplicationFabricId) (result RemoveInfraOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/removeInfra", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RemoveInfraThenPoll performs RemoveInfra then polls until it's completed +func (c ReplicationFabricsClient) RemoveInfraThenPoll(ctx context.Context, id ReplicationFabricId) error { + result, err := c.RemoveInfra(ctx, id) + if err != nil { + return fmt.Errorf("performing RemoveInfra: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RemoveInfra: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_renewcertificate.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_renewcertificate.go new file mode 100644 index 00000000000..ed91ffffebd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/method_renewcertificate.go @@ -0,0 +1,75 @@ +package replicationfabrics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Fabric +} + +// RenewCertificate ... +func (c ReplicationFabricsClient) RenewCertificate(ctx context.Context, id ReplicationFabricId, input RenewCertificateInput) (result RenewCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/renewCertificate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RenewCertificateThenPoll performs RenewCertificate then polls until it's completed +func (c ReplicationFabricsClient) RenewCertificateThenPoll(ctx context.Context, id ReplicationFabricId, input RenewCertificateInput) error { + result, err := c.RenewCertificate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RenewCertificate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RenewCertificate: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_a2aextendedlocationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_a2aextendedlocationdetails.go new file mode 100644 index 00000000000..4c3f270376d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_a2aextendedlocationdetails.go @@ -0,0 +1,13 @@ +package replicationfabrics + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AExtendedLocationDetails struct { + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_a2afabricspecificlocationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_a2afabricspecificlocationdetails.go new file mode 100644 index 00000000000..cf5d60d8f06 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_a2afabricspecificlocationdetails.go @@ -0,0 +1,23 @@ +package replicationfabrics + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AFabricSpecificLocationDetails struct { + InitialPrimaryExtendedLocation *edgezones.Model `json:"initialPrimaryExtendedLocation,omitempty"` + InitialPrimaryFabricLocation *string `json:"initialPrimaryFabricLocation,omitempty"` + InitialPrimaryZone *string `json:"initialPrimaryZone,omitempty"` + InitialRecoveryExtendedLocation *edgezones.Model `json:"initialRecoveryExtendedLocation,omitempty"` + InitialRecoveryFabricLocation *string `json:"initialRecoveryFabricLocation,omitempty"` + InitialRecoveryZone *string `json:"initialRecoveryZone,omitempty"` + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + PrimaryZone *string `json:"primaryZone,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` + RecoveryZone *string `json:"recoveryZone,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_a2azonedetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_a2azonedetails.go new file mode 100644 index 00000000000..f4ad23d1c8c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_a2azonedetails.go @@ -0,0 +1,9 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AZoneDetails struct { + Source *string `json:"source,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_agentdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_agentdetails.go new file mode 100644 index 00000000000..ec30bdfa82c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_agentdetails.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentDetails struct { + AgentId *string `json:"agentId,omitempty"` + BiosId *string `json:"biosId,omitempty"` + Disks *[]AgentDiskDetails `json:"disks,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + MachineId *string `json:"machineId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_agentdiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_agentdiskdetails.go new file mode 100644 index 00000000000..be3e096778e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_agentdiskdetails.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentDiskDetails struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + LunId *int64 `json:"lunId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_azurefabriccreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_azurefabriccreationinput.go new file mode 100644 index 00000000000..738d129adb3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_azurefabriccreationinput.go @@ -0,0 +1,50 @@ +package replicationfabrics + +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 _ FabricSpecificCreationInput = AzureFabricCreationInput{} + +type AzureFabricCreationInput struct { + Location *string `json:"location,omitempty"` + + // Fields inherited from FabricSpecificCreationInput + + InstanceType string `json:"instanceType"` +} + +func (s AzureFabricCreationInput) FabricSpecificCreationInput() BaseFabricSpecificCreationInputImpl { + return BaseFabricSpecificCreationInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = AzureFabricCreationInput{} + +func (s AzureFabricCreationInput) MarshalJSON() ([]byte, error) { + type wrapper AzureFabricCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFabricCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFabricCreationInput: %+v", err) + } + + decoded["instanceType"] = "Azure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFabricCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_azurefabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_azurefabricspecificdetails.go new file mode 100644 index 00000000000..e654364c02c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_azurefabricspecificdetails.go @@ -0,0 +1,54 @@ +package replicationfabrics + +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 _ FabricSpecificDetails = AzureFabricSpecificDetails{} + +type AzureFabricSpecificDetails struct { + ContainerIds *[]string `json:"containerIds,omitempty"` + ExtendedLocations *[]A2AExtendedLocationDetails `json:"extendedLocations,omitempty"` + Location *string `json:"location,omitempty"` + LocationDetails *[]A2AFabricSpecificLocationDetails `json:"locationDetails,omitempty"` + Zones *[]A2AZoneDetails `json:"zones,omitempty"` + + // Fields inherited from FabricSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s AzureFabricSpecificDetails) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return BaseFabricSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = AzureFabricSpecificDetails{} + +func (s AzureFabricSpecificDetails) MarshalJSON() ([]byte, error) { + type wrapper AzureFabricSpecificDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFabricSpecificDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFabricSpecificDetails: %+v", err) + } + + decoded["instanceType"] = "Azure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFabricSpecificDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_datastore.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_datastore.go new file mode 100644 index 00000000000..e20a79fe8fe --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_datastore.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataStore struct { + Capacity *string `json:"capacity,omitempty"` + FreeSpace *string `json:"freeSpace,omitempty"` + SymbolicName *string `json:"symbolicName,omitempty"` + Type *string `json:"type,omitempty"` + Uuid *string `json:"uuid,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_dradetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_dradetails.go new file mode 100644 index 00000000000..3e205a58dff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_dradetails.go @@ -0,0 +1,34 @@ +package replicationfabrics + +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 DraDetails struct { + BiosId *string `json:"biosId,omitempty"` + ForwardProtectedItemCount *int64 `json:"forwardProtectedItemCount,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + ReverseProtectedItemCount *int64 `json:"reverseProtectedItemCount,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *DraDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *DraDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_encryptiondetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_encryptiondetails.go new file mode 100644 index 00000000000..75278c5e8f0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_encryptiondetails.go @@ -0,0 +1,28 @@ +package replicationfabrics + +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 EncryptionDetails struct { + KekCertExpiryDate *string `json:"kekCertExpiryDate,omitempty"` + KekCertThumbprint *string `json:"kekCertThumbprint,omitempty"` + KekState *string `json:"kekState,omitempty"` +} + +func (o *EncryptionDetails) GetKekCertExpiryDateAsTime() (*time.Time, error) { + if o.KekCertExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.KekCertExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *EncryptionDetails) SetKekCertExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.KekCertExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabric.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabric.go new file mode 100644 index 00000000000..025c3ea019c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabric.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Fabric struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FabricProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabriccreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabriccreationinput.go new file mode 100644 index 00000000000..33f8bdc704c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabriccreationinput.go @@ -0,0 +1,8 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FabricCreationInput struct { + Properties *FabricCreationInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabriccreationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabriccreationinputproperties.go new file mode 100644 index 00000000000..b78f44518cc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabriccreationinputproperties.go @@ -0,0 +1,33 @@ +package replicationfabrics + +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 FabricCreationInputProperties struct { + CustomDetails FabricSpecificCreationInput `json:"customDetails"` +} + +var _ json.Unmarshaler = &FabricCreationInputProperties{} + +func (s *FabricCreationInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling FabricCreationInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := UnmarshalFabricSpecificCreationInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'FabricCreationInputProperties': %+v", err) + } + s.CustomDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabricproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabricproperties.go new file mode 100644 index 00000000000..821456e11eb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabricproperties.go @@ -0,0 +1,60 @@ +package replicationfabrics + +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 FabricProperties struct { + BcdrState *string `json:"bcdrState,omitempty"` + CustomDetails FabricSpecificDetails `json:"customDetails"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Health *string `json:"health,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + InternalIdentifier *string `json:"internalIdentifier,omitempty"` + RolloverEncryptionDetails *EncryptionDetails `json:"rolloverEncryptionDetails,omitempty"` +} + +var _ json.Unmarshaler = &FabricProperties{} + +func (s *FabricProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + BcdrState *string `json:"bcdrState,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Health *string `json:"health,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + InternalIdentifier *string `json:"internalIdentifier,omitempty"` + RolloverEncryptionDetails *EncryptionDetails `json:"rolloverEncryptionDetails,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.BcdrState = decoded.BcdrState + s.EncryptionDetails = decoded.EncryptionDetails + s.FriendlyName = decoded.FriendlyName + s.Health = decoded.Health + s.HealthErrorDetails = decoded.HealthErrorDetails + s.InternalIdentifier = decoded.InternalIdentifier + s.RolloverEncryptionDetails = decoded.RolloverEncryptionDetails + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling FabricProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := UnmarshalFabricSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'FabricProperties': %+v", err) + } + s.CustomDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabricspecificcreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabricspecificcreationinput.go new file mode 100644 index 00000000000..128f14469f7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabricspecificcreationinput.go @@ -0,0 +1,91 @@ +package replicationfabrics + +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 FabricSpecificCreationInput interface { + FabricSpecificCreationInput() BaseFabricSpecificCreationInputImpl +} + +var _ FabricSpecificCreationInput = BaseFabricSpecificCreationInputImpl{} + +type BaseFabricSpecificCreationInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseFabricSpecificCreationInputImpl) FabricSpecificCreationInput() BaseFabricSpecificCreationInputImpl { + return s +} + +var _ FabricSpecificCreationInput = RawFabricSpecificCreationInputImpl{} + +// RawFabricSpecificCreationInputImpl 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 RawFabricSpecificCreationInputImpl struct { + fabricSpecificCreationInput BaseFabricSpecificCreationInputImpl + Type string + Values map[string]interface{} +} + +func (s RawFabricSpecificCreationInputImpl) FabricSpecificCreationInput() BaseFabricSpecificCreationInputImpl { + return s.fabricSpecificCreationInput +} + +func UnmarshalFabricSpecificCreationInputImplementation(input []byte) (FabricSpecificCreationInput, 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 FabricSpecificCreationInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Azure") { + var out AzureFabricCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFabricCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmFabricCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFabricCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareV2") { + var out VMwareV2FabricCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareV2FabricCreationInput: %+v", err) + } + return out, nil + } + + var parent BaseFabricSpecificCreationInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFabricSpecificCreationInputImpl: %+v", err) + } + + return RawFabricSpecificCreationInputImpl{ + fabricSpecificCreationInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabricspecificdetails.go new file mode 100644 index 00000000000..be6b1c113b5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_fabricspecificdetails.go @@ -0,0 +1,115 @@ +package replicationfabrics + +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 FabricSpecificDetails interface { + FabricSpecificDetails() BaseFabricSpecificDetailsImpl +} + +var _ FabricSpecificDetails = BaseFabricSpecificDetailsImpl{} + +type BaseFabricSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseFabricSpecificDetailsImpl) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return s +} + +var _ FabricSpecificDetails = RawFabricSpecificDetailsImpl{} + +// RawFabricSpecificDetailsImpl 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 RawFabricSpecificDetailsImpl struct { + fabricSpecificDetails BaseFabricSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawFabricSpecificDetailsImpl) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return s.fabricSpecificDetails +} + +func UnmarshalFabricSpecificDetailsImplementation(input []byte) (FabricSpecificDetails, 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 FabricSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Azure") { + var out AzureFabricSpecificDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFabricSpecificDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVSite") { + var out HyperVSiteDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVSiteDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmFabricSpecificDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFabricSpecificDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMM") { + var out VMmDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMware") { + var out VMwareDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareV2") { + var out VMwareV2FabricSpecificDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareV2FabricSpecificDetails: %+v", err) + } + return out, nil + } + + var parent BaseFabricSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFabricSpecificDetailsImpl: %+v", err) + } + + return RawFabricSpecificDetailsImpl{ + fabricSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_failoverprocessserverrequest.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_failoverprocessserverrequest.go new file mode 100644 index 00000000000..f782d62e870 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_failoverprocessserverrequest.go @@ -0,0 +1,8 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverProcessServerRequest struct { + Properties *FailoverProcessServerRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_failoverprocessserverrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_failoverprocessserverrequestproperties.go new file mode 100644 index 00000000000..03ea6958e5d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_failoverprocessserverrequestproperties.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverProcessServerRequestProperties struct { + ContainerName *string `json:"containerName,omitempty"` + SourceProcessServerId *string `json:"sourceProcessServerId,omitempty"` + TargetProcessServerId *string `json:"targetProcessServerId,omitempty"` + UpdateType *string `json:"updateType,omitempty"` + VMsToMigrate *[]string `json:"vmsToMigrate,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_healtherror.go new file mode 100644 index 00000000000..50dfa0a791d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationfabrics + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_hypervhostdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_hypervhostdetails.go new file mode 100644 index 00000000000..5a5914edea0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_hypervhostdetails.go @@ -0,0 +1,10 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HyperVHostDetails struct { + Id *string `json:"id,omitempty"` + MarsAgentVersion *string `json:"marsAgentVersion,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_hypervsitedetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_hypervsitedetails.go new file mode 100644 index 00000000000..35716f3e90a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_hypervsitedetails.go @@ -0,0 +1,50 @@ +package replicationfabrics + +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 _ FabricSpecificDetails = HyperVSiteDetails{} + +type HyperVSiteDetails struct { + HyperVHosts *[]HyperVHostDetails `json:"hyperVHosts,omitempty"` + + // Fields inherited from FabricSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVSiteDetails) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return BaseFabricSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVSiteDetails{} + +func (s HyperVSiteDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVSiteDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVSiteDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVSiteDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVSite" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVSiteDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_identityproviderdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_identityproviderdetails.go new file mode 100644 index 00000000000..0a005565876 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_identityproviderdetails.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviderDetails struct { + AadAuthority *string `json:"aadAuthority,omitempty"` + ApplicationId *string `json:"applicationId,omitempty"` + Audience *string `json:"audience,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_identityproviderinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_identityproviderinput.go new file mode 100644 index 00000000000..95277e41cc9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_identityproviderinput.go @@ -0,0 +1,12 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviderInput struct { + AadAuthority string `json:"aadAuthority"` + ApplicationId string `json:"applicationId"` + Audience string `json:"audience"` + ObjectId string `json:"objectId"` + TenantId string `json:"tenantId"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_inmagefabricswitchproviderblockingerrordetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_inmagefabricswitchproviderblockingerrordetails.go new file mode 100644 index 00000000000..665f9db6edb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_inmagefabricswitchproviderblockingerrordetails.go @@ -0,0 +1,13 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageFabricSwitchProviderBlockingErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_inmagercmfabriccreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_inmagercmfabriccreationinput.go new file mode 100644 index 00000000000..9e072625014 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_inmagercmfabriccreationinput.go @@ -0,0 +1,52 @@ +package replicationfabrics + +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 _ FabricSpecificCreationInput = InMageRcmFabricCreationInput{} + +type InMageRcmFabricCreationInput struct { + PhysicalSiteId string `json:"physicalSiteId"` + SourceAgentIdentity IdentityProviderInput `json:"sourceAgentIdentity"` + VMwareSiteId string `json:"vmwareSiteId"` + + // Fields inherited from FabricSpecificCreationInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFabricCreationInput) FabricSpecificCreationInput() BaseFabricSpecificCreationInputImpl { + return BaseFabricSpecificCreationInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFabricCreationInput{} + +func (s InMageRcmFabricCreationInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFabricCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFabricCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFabricCreationInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFabricCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_inmagercmfabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_inmagercmfabricspecificdetails.go new file mode 100644 index 00000000000..4e138321c6f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_inmagercmfabricspecificdetails.go @@ -0,0 +1,65 @@ +package replicationfabrics + +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 _ FabricSpecificDetails = InMageRcmFabricSpecificDetails{} + +type InMageRcmFabricSpecificDetails struct { + AgentDetails *[]AgentDetails `json:"agentDetails,omitempty"` + ControlPlaneUri *string `json:"controlPlaneUri,omitempty"` + DataPlaneUri *string `json:"dataPlaneUri,omitempty"` + Dras *[]DraDetails `json:"dras,omitempty"` + MarsAgents *[]MarsAgentDetails `json:"marsAgents,omitempty"` + PhysicalSiteId *string `json:"physicalSiteId,omitempty"` + ProcessServers *[]ProcessServerDetails `json:"processServers,omitempty"` + PushInstallers *[]PushInstallerDetails `json:"pushInstallers,omitempty"` + RcmProxies *[]RcmProxyDetails `json:"rcmProxies,omitempty"` + ReplicationAgents *[]ReplicationAgentDetails `json:"replicationAgents,omitempty"` + ReprotectAgents *[]ReprotectAgentDetails `json:"reprotectAgents,omitempty"` + ServiceContainerId *string `json:"serviceContainerId,omitempty"` + ServiceEndpoint *string `json:"serviceEndpoint,omitempty"` + ServiceResourceId *string `json:"serviceResourceId,omitempty"` + SourceAgentIdentityDetails *IdentityProviderDetails `json:"sourceAgentIdentityDetails,omitempty"` + VMwareSiteId *string `json:"vmwareSiteId,omitempty"` + + // Fields inherited from FabricSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFabricSpecificDetails) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return BaseFabricSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFabricSpecificDetails{} + +func (s InMageRcmFabricSpecificDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFabricSpecificDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFabricSpecificDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFabricSpecificDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFabricSpecificDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_innerhealtherror.go new file mode 100644 index 00000000000..c14191f79bd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationfabrics + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_marsagentdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_marsagentdetails.go new file mode 100644 index 00000000000..ed4c6a9d572 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_marsagentdetails.go @@ -0,0 +1,34 @@ +package replicationfabrics + +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 MarsAgentDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *MarsAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *MarsAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_mastertargetserver.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_mastertargetserver.go new file mode 100644 index 00000000000..a5e06f8b4a6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_mastertargetserver.go @@ -0,0 +1,67 @@ +package replicationfabrics + +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 MasterTargetServer struct { + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AgentVersionDetails *VersionDetails `json:"agentVersionDetails,omitempty"` + DataStores *[]DataStore `json:"dataStores,omitempty"` + DiskCount *int64 `json:"diskCount,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + MarsAgentExpiryDate *string `json:"marsAgentExpiryDate,omitempty"` + MarsAgentVersion *string `json:"marsAgentVersion,omitempty"` + MarsAgentVersionDetails *VersionDetails `json:"marsAgentVersionDetails,omitempty"` + Name *string `json:"name,omitempty"` + OsType *string `json:"osType,omitempty"` + OsVersion *string `json:"osVersion,omitempty"` + RetentionVolumes *[]RetentionVolume `json:"retentionVolumes,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` + VersionStatus *string `json:"versionStatus,omitempty"` +} + +func (o *MasterTargetServer) GetAgentExpiryDateAsTime() (*time.Time, error) { + if o.AgentExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *MasterTargetServer) SetAgentExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentExpiryDate = &formatted +} + +func (o *MasterTargetServer) GetLastHeartbeatAsTime() (*time.Time, error) { + if o.LastHeartbeat == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeat, "2006-01-02T15:04:05Z07:00") +} + +func (o *MasterTargetServer) SetLastHeartbeatAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeat = &formatted +} + +func (o *MasterTargetServer) GetMarsAgentExpiryDateAsTime() (*time.Time, error) { + if o.MarsAgentExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.MarsAgentExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *MasterTargetServer) SetMarsAgentExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.MarsAgentExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_mobilityserviceupdate.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_mobilityserviceupdate.go new file mode 100644 index 00000000000..aa2c9c06e41 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_mobilityserviceupdate.go @@ -0,0 +1,10 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MobilityServiceUpdate struct { + OsType *string `json:"osType,omitempty"` + RebootStatus *string `json:"rebootStatus,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_processserver.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_processserver.go new file mode 100644 index 00000000000..60022e3bd47 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_processserver.go @@ -0,0 +1,97 @@ +package replicationfabrics + +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 ProcessServer struct { + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AgentVersionDetails *VersionDetails `json:"agentVersionDetails,omitempty"` + AvailableMemoryInBytes *int64 `json:"availableMemoryInBytes,omitempty"` + AvailableSpaceInBytes *int64 `json:"availableSpaceInBytes,omitempty"` + CpuLoad *string `json:"cpuLoad,omitempty"` + CpuLoadStatus *string `json:"cpuLoadStatus,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + HostId *string `json:"hostId,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + MachineCount *string `json:"machineCount,omitempty"` + MarsCommunicationStatus *string `json:"marsCommunicationStatus,omitempty"` + MarsRegistrationStatus *string `json:"marsRegistrationStatus,omitempty"` + MemoryUsageStatus *string `json:"memoryUsageStatus,omitempty"` + MobilityServiceUpdates *[]MobilityServiceUpdate `json:"mobilityServiceUpdates,omitempty"` + OsType *string `json:"osType,omitempty"` + OsVersion *string `json:"osVersion,omitempty"` + PsServiceStatus *string `json:"psServiceStatus,omitempty"` + PsStatsRefreshTime *string `json:"psStatsRefreshTime,omitempty"` + ReplicationPairCount *string `json:"replicationPairCount,omitempty"` + SpaceUsageStatus *string `json:"spaceUsageStatus,omitempty"` + SslCertExpiryDate *string `json:"sslCertExpiryDate,omitempty"` + SslCertExpiryRemainingDays *int64 `json:"sslCertExpiryRemainingDays,omitempty"` + SystemLoad *string `json:"systemLoad,omitempty"` + SystemLoadStatus *string `json:"systemLoadStatus,omitempty"` + ThroughputInBytes *int64 `json:"throughputInBytes,omitempty"` + ThroughputInMBps *int64 `json:"throughputInMBps,omitempty"` + ThroughputStatus *string `json:"throughputStatus,omitempty"` + ThroughputUploadPendingDataInBytes *int64 `json:"throughputUploadPendingDataInBytes,omitempty"` + TotalMemoryInBytes *int64 `json:"totalMemoryInBytes,omitempty"` + TotalSpaceInBytes *int64 `json:"totalSpaceInBytes,omitempty"` + VersionStatus *string `json:"versionStatus,omitempty"` +} + +func (o *ProcessServer) GetAgentExpiryDateAsTime() (*time.Time, error) { + if o.AgentExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServer) SetAgentExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentExpiryDate = &formatted +} + +func (o *ProcessServer) GetLastHeartbeatAsTime() (*time.Time, error) { + if o.LastHeartbeat == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeat, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServer) SetLastHeartbeatAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeat = &formatted +} + +func (o *ProcessServer) GetPsStatsRefreshTimeAsTime() (*time.Time, error) { + if o.PsStatsRefreshTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.PsStatsRefreshTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServer) SetPsStatsRefreshTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.PsStatsRefreshTime = &formatted +} + +func (o *ProcessServer) GetSslCertExpiryDateAsTime() (*time.Time, error) { + if o.SslCertExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SslCertExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServer) SetSslCertExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SslCertExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_processserverdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_processserverdetails.go new file mode 100644 index 00000000000..dd4118b12a9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_processserverdetails.go @@ -0,0 +1,54 @@ +package replicationfabrics + +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 ProcessServerDetails struct { + AvailableMemoryInBytes *int64 `json:"availableMemoryInBytes,omitempty"` + AvailableSpaceInBytes *int64 `json:"availableSpaceInBytes,omitempty"` + BiosId *string `json:"biosId,omitempty"` + DiskUsageStatus *RcmComponentStatus `json:"diskUsageStatus,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + FreeSpacePercentage *float64 `json:"freeSpacePercentage,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + HistoricHealth *ProtectionHealth `json:"historicHealth,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + MemoryUsagePercentage *float64 `json:"memoryUsagePercentage,omitempty"` + MemoryUsageStatus *RcmComponentStatus `json:"memoryUsageStatus,omitempty"` + Name *string `json:"name,omitempty"` + ProcessorUsagePercentage *float64 `json:"processorUsagePercentage,omitempty"` + ProcessorUsageStatus *RcmComponentStatus `json:"processorUsageStatus,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + SystemLoad *int64 `json:"systemLoad,omitempty"` + SystemLoadStatus *RcmComponentStatus `json:"systemLoadStatus,omitempty"` + ThroughputInBytes *int64 `json:"throughputInBytes,omitempty"` + ThroughputStatus *RcmComponentStatus `json:"throughputStatus,omitempty"` + ThroughputUploadPendingDataInBytes *int64 `json:"throughputUploadPendingDataInBytes,omitempty"` + TotalMemoryInBytes *int64 `json:"totalMemoryInBytes,omitempty"` + TotalSpaceInBytes *int64 `json:"totalSpaceInBytes,omitempty"` + UsedMemoryInBytes *int64 `json:"usedMemoryInBytes,omitempty"` + UsedSpaceInBytes *int64 `json:"usedSpaceInBytes,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ProcessServerDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessServerDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_pushinstallerdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_pushinstallerdetails.go new file mode 100644 index 00000000000..e12d0506fab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_pushinstallerdetails.go @@ -0,0 +1,34 @@ +package replicationfabrics + +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 PushInstallerDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *PushInstallerDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *PushInstallerDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_rcmproxydetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_rcmproxydetails.go new file mode 100644 index 00000000000..939904987ef --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_rcmproxydetails.go @@ -0,0 +1,35 @@ +package replicationfabrics + +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 RcmProxyDetails struct { + BiosId *string `json:"biosId,omitempty"` + ClientAuthenticationType *string `json:"clientAuthenticationType,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *RcmProxyDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *RcmProxyDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_renewcertificateinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_renewcertificateinput.go new file mode 100644 index 00000000000..ab4a712f42d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_renewcertificateinput.go @@ -0,0 +1,8 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateInput struct { + Properties *RenewCertificateInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_renewcertificateinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_renewcertificateinputproperties.go new file mode 100644 index 00000000000..bf4f0b8030e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_renewcertificateinputproperties.go @@ -0,0 +1,8 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateInputProperties struct { + RenewCertificateType *string `json:"renewCertificateType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_replicationagentdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_replicationagentdetails.go new file mode 100644 index 00000000000..0e9ca7038c8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_replicationagentdetails.go @@ -0,0 +1,34 @@ +package replicationfabrics + +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 ReplicationAgentDetails struct { + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ReplicationAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_reprotectagentdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_reprotectagentdetails.go new file mode 100644 index 00000000000..61e5cf92ba5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_reprotectagentdetails.go @@ -0,0 +1,50 @@ +package replicationfabrics + +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 ReprotectAgentDetails struct { + AccessibleDatastores *[]string `json:"accessibleDatastores,omitempty"` + BiosId *string `json:"biosId,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + Id *string `json:"id,omitempty"` + LastDiscoveryInUtc *string `json:"lastDiscoveryInUtc,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + Name *string `json:"name,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + VcenterId *string `json:"vcenterId,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *ReprotectAgentDetails) GetLastDiscoveryInUtcAsTime() (*time.Time, error) { + if o.LastDiscoveryInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastDiscoveryInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReprotectAgentDetails) SetLastDiscoveryInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastDiscoveryInUtc = &formatted +} + +func (o *ReprotectAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReprotectAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_retentionvolume.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_retentionvolume.go new file mode 100644 index 00000000000..7d9aa7c6801 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_retentionvolume.go @@ -0,0 +1,11 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionVolume struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + FreeSpaceInBytes *int64 `json:"freeSpaceInBytes,omitempty"` + ThresholdPercentage *int64 `json:"thresholdPercentage,omitempty"` + VolumeName *string `json:"volumeName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_runasaccount.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_runasaccount.go new file mode 100644 index 00000000000..2339edd7049 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_runasaccount.go @@ -0,0 +1,9 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunAsAccount struct { + AccountId *string `json:"accountId,omitempty"` + AccountName *string `json:"accountName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_versiondetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_versiondetails.go new file mode 100644 index 00000000000..5d74eb7597e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_versiondetails.go @@ -0,0 +1,28 @@ +package replicationfabrics + +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 VersionDetails struct { + ExpiryDate *string `json:"expiryDate,omitempty"` + Status *AgentVersionStatus `json:"status,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *VersionDetails) GetExpiryDateAsTime() (*time.Time, error) { + if o.ExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *VersionDetails) SetExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_vmmdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_vmmdetails.go new file mode 100644 index 00000000000..cb33769db25 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_vmmdetails.go @@ -0,0 +1,49 @@ +package replicationfabrics + +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 _ FabricSpecificDetails = VMmDetails{} + +type VMmDetails struct { + + // Fields inherited from FabricSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s VMmDetails) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return BaseFabricSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmDetails{} + +func (s VMmDetails) MarshalJSON() ([]byte, error) { + type wrapper VMmDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmDetails: %+v", err) + } + + decoded["instanceType"] = "VMM" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_vmwaredetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_vmwaredetails.go new file mode 100644 index 00000000000..097a880d515 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_vmwaredetails.go @@ -0,0 +1,82 @@ +package replicationfabrics + +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 _ FabricSpecificDetails = VMwareDetails{} + +type VMwareDetails struct { + AgentCount *string `json:"agentCount,omitempty"` + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AgentVersionDetails *VersionDetails `json:"agentVersionDetails,omitempty"` + AvailableMemoryInBytes *int64 `json:"availableMemoryInBytes,omitempty"` + AvailableSpaceInBytes *int64 `json:"availableSpaceInBytes,omitempty"` + CpuLoad *string `json:"cpuLoad,omitempty"` + CpuLoadStatus *string `json:"cpuLoadStatus,omitempty"` + CsServiceStatus *string `json:"csServiceStatus,omitempty"` + DatabaseServerLoad *string `json:"databaseServerLoad,omitempty"` + DatabaseServerLoadStatus *string `json:"databaseServerLoadStatus,omitempty"` + HostName *string `json:"hostName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + MasterTargetServers *[]MasterTargetServer `json:"masterTargetServers,omitempty"` + MemoryUsageStatus *string `json:"memoryUsageStatus,omitempty"` + ProcessServerCount *string `json:"processServerCount,omitempty"` + ProcessServers *[]ProcessServer `json:"processServers,omitempty"` + ProtectedServers *string `json:"protectedServers,omitempty"` + PsTemplateVersion *string `json:"psTemplateVersion,omitempty"` + ReplicationPairCount *string `json:"replicationPairCount,omitempty"` + RunAsAccounts *[]RunAsAccount `json:"runAsAccounts,omitempty"` + SpaceUsageStatus *string `json:"spaceUsageStatus,omitempty"` + SslCertExpiryDate *string `json:"sslCertExpiryDate,omitempty"` + SslCertExpiryRemainingDays *int64 `json:"sslCertExpiryRemainingDays,omitempty"` + SwitchProviderBlockingErrorDetails *[]InMageFabricSwitchProviderBlockingErrorDetails `json:"switchProviderBlockingErrorDetails,omitempty"` + SystemLoad *string `json:"systemLoad,omitempty"` + SystemLoadStatus *string `json:"systemLoadStatus,omitempty"` + TotalMemoryInBytes *int64 `json:"totalMemoryInBytes,omitempty"` + TotalSpaceInBytes *int64 `json:"totalSpaceInBytes,omitempty"` + VersionStatus *string `json:"versionStatus,omitempty"` + WebLoad *string `json:"webLoad,omitempty"` + WebLoadStatus *string `json:"webLoadStatus,omitempty"` + + // Fields inherited from FabricSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s VMwareDetails) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return BaseFabricSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareDetails{} + +func (s VMwareDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareDetails: %+v", err) + } + + decoded["instanceType"] = "VMware" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_vmwarev2fabriccreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_vmwarev2fabriccreationinput.go new file mode 100644 index 00000000000..16600cfb322 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_vmwarev2fabriccreationinput.go @@ -0,0 +1,52 @@ +package replicationfabrics + +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 _ FabricSpecificCreationInput = VMwareV2FabricCreationInput{} + +type VMwareV2FabricCreationInput struct { + MigrationSolutionId string `json:"migrationSolutionId"` + PhysicalSiteId *string `json:"physicalSiteId,omitempty"` + VMwareSiteId *string `json:"vmwareSiteId,omitempty"` + + // Fields inherited from FabricSpecificCreationInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareV2FabricCreationInput) FabricSpecificCreationInput() BaseFabricSpecificCreationInputImpl { + return BaseFabricSpecificCreationInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareV2FabricCreationInput{} + +func (s VMwareV2FabricCreationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareV2FabricCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareV2FabricCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareV2FabricCreationInput: %+v", err) + } + + decoded["instanceType"] = "VMwareV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareV2FabricCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_vmwarev2fabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_vmwarev2fabricspecificdetails.go new file mode 100644 index 00000000000..5ff33f8b551 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/model_vmwarev2fabricspecificdetails.go @@ -0,0 +1,56 @@ +package replicationfabrics + +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 _ FabricSpecificDetails = VMwareV2FabricSpecificDetails{} + +type VMwareV2FabricSpecificDetails struct { + MigrationSolutionId *string `json:"migrationSolutionId,omitempty"` + PhysicalSiteId *string `json:"physicalSiteId,omitempty"` + ProcessServers *[]ProcessServerDetails `json:"processServers,omitempty"` + ServiceContainerId *string `json:"serviceContainerId,omitempty"` + ServiceEndpoint *string `json:"serviceEndpoint,omitempty"` + ServiceResourceId *string `json:"serviceResourceId,omitempty"` + VMwareSiteId *string `json:"vmwareSiteId,omitempty"` + + // Fields inherited from FabricSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s VMwareV2FabricSpecificDetails) FabricSpecificDetails() BaseFabricSpecificDetailsImpl { + return BaseFabricSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareV2FabricSpecificDetails{} + +func (s VMwareV2FabricSpecificDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareV2FabricSpecificDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareV2FabricSpecificDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareV2FabricSpecificDetails: %+v", err) + } + + decoded["instanceType"] = "VMwareV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareV2FabricSpecificDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/predicates.go new file mode 100644 index 00000000000..faded6326cb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/predicates.go @@ -0,0 +1,32 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FabricOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p FabricOperationPredicate) Matches(input Fabric) 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/recoveryservicessiterecovery/2025-02-01/replicationfabrics/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/version.go new file mode 100644 index 00000000000..117eb044f9a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationfabrics/version.go @@ -0,0 +1,10 @@ +package replicationfabrics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationfabrics/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/README.md new file mode 100644 index 00000000000..45bec20120d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs` Documentation + +The `replicationjobs` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationjobs" +``` + + +### Client Initialization + +```go +client := replicationjobs.NewReplicationJobsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationJobsClient.Cancel` + +```go +ctx := context.TODO() +id := replicationjobs.NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationJobName") + +if err := client.CancelThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationJobsClient.Export` + +```go +ctx := context.TODO() +id := replicationjobs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +payload := replicationjobs.JobQueryParameter{ + // ... +} + + +if err := client.ExportThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationJobsClient.Get` + +```go +ctx := context.TODO() +id := replicationjobs.NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationJobName") + +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: `ReplicationJobsClient.List` + +```go +ctx := context.TODO() +id := replicationjobs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, replicationjobs.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationjobs.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationJobsClient.Restart` + +```go +ctx := context.TODO() +id := replicationjobs.NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationJobName") + +if err := client.RestartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationJobsClient.Resume` + +```go +ctx := context.TODO() +id := replicationjobs.NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationJobName") + +payload := replicationjobs.ResumeJobParams{ + // ... +} + + +if err := client.ResumeThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/client.go new file mode 100644 index 00000000000..0fb616b34c6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/client.go @@ -0,0 +1,26 @@ +package replicationjobs + +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 ReplicationJobsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationJobsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationJobsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationjobs", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationJobsClient: %+v", err) + } + + return &ReplicationJobsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/constants.go new file mode 100644 index 00000000000..2ad7334b254 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/constants.go @@ -0,0 +1,54 @@ +package replicationjobs + +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 ExportJobOutputSerializationType string + +const ( + ExportJobOutputSerializationTypeExcel ExportJobOutputSerializationType = "Excel" + ExportJobOutputSerializationTypeJson ExportJobOutputSerializationType = "Json" + ExportJobOutputSerializationTypeXml ExportJobOutputSerializationType = "Xml" +) + +func PossibleValuesForExportJobOutputSerializationType() []string { + return []string{ + string(ExportJobOutputSerializationTypeExcel), + string(ExportJobOutputSerializationTypeJson), + string(ExportJobOutputSerializationTypeXml), + } +} + +func (s *ExportJobOutputSerializationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExportJobOutputSerializationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExportJobOutputSerializationType(input string) (*ExportJobOutputSerializationType, error) { + vals := map[string]ExportJobOutputSerializationType{ + "excel": ExportJobOutputSerializationTypeExcel, + "json": ExportJobOutputSerializationTypeJson, + "xml": ExportJobOutputSerializationTypeXml, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExportJobOutputSerializationType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/id_replicationjob.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/id_replicationjob.go new file mode 100644 index 00000000000..4abf5a4a7be --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/id_replicationjob.go @@ -0,0 +1,139 @@ +package replicationjobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationJobId{}) +} + +var _ resourceids.ResourceId = &ReplicationJobId{} + +// ReplicationJobId is a struct representing the Resource ID for a Replication Job +type ReplicationJobId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationJobName string +} + +// NewReplicationJobID returns a new ReplicationJobId struct +func NewReplicationJobID(subscriptionId string, resourceGroupName string, vaultName string, replicationJobName string) ReplicationJobId { + return ReplicationJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationJobName: replicationJobName, + } +} + +// ParseReplicationJobID parses 'input' into a ReplicationJobId +func ParseReplicationJobID(input string) (*ReplicationJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationJobIDInsensitively parses 'input' case-insensitively into a ReplicationJobId +// note: this method should only be used for API response data and not user input +func ParseReplicationJobIDInsensitively(input string) (*ReplicationJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationJobId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationJobName, ok = input.Parsed["replicationJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationJobName", input) + } + + return nil +} + +// ValidateReplicationJobID checks that 'input' can be parsed as a Replication Job ID +func ValidateReplicationJobID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Job ID +func (id ReplicationJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Job ID +func (id ReplicationJobId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationJobs", "replicationJobs", "replicationJobs"), + resourceids.UserSpecifiedSegment("replicationJobName", "replicationJobName"), + } +} + +// String returns a human-readable description of this Replication Job ID +func (id ReplicationJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Job Name: %q", id.ReplicationJobName), + } + return fmt.Sprintf("Replication Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/id_replicationjob_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/id_replicationjob_test.go new file mode 100644 index 00000000000..1f54c3772b8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/id_replicationjob_test.go @@ -0,0 +1,327 @@ +package replicationjobs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationJobId{} + +func TestNewReplicationJobID(t *testing.T) { + id := NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationJobName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationJobName != "replicationJobName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationJobName'", id.ReplicationJobName, "replicationJobName") + } +} + +func TestFormatReplicationJobID(t *testing.T) { + actual := NewReplicationJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationJobs/replicationJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationJobs/replicationJobName", + Expected: &ReplicationJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationJobName: "replicationJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationJobs/replicationJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationJobName != v.Expected.ReplicationJobName { + t.Fatalf("Expected %q but got %q for ReplicationJobName", v.Expected.ReplicationJobName, actual.ReplicationJobName) + } + + } +} + +func TestParseReplicationJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationJobs/replicationJobName", + Expected: &ReplicationJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationJobName: "replicationJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationJobs/replicationJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnJoBs/rEpLiCaTiOnJoBnAmE", + Expected: &ReplicationJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationJobName: "rEpLiCaTiOnJoBnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnJoBs/rEpLiCaTiOnJoBnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationJobName != v.Expected.ReplicationJobName { + t.Fatalf("Expected %q but got %q for ReplicationJobName", v.Expected.ReplicationJobName, actual.ReplicationJobName) + } + + } +} + +func TestSegmentsForReplicationJobId(t *testing.T) { + segments := ReplicationJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationJobId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/id_vault.go new file mode 100644 index 00000000000..da6fbb451d2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/id_vault.go @@ -0,0 +1,130 @@ +package replicationjobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/id_vault_test.go new file mode 100644 index 00000000000..33e578b5b44 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationjobs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_cancel.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_cancel.go new file mode 100644 index 00000000000..6bb93c09237 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_cancel.go @@ -0,0 +1,71 @@ +package replicationjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// Cancel ... +func (c ReplicationJobsClient) Cancel(ctx context.Context, id ReplicationJobId) (result CancelOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CancelThenPoll performs Cancel then polls until it's completed +func (c ReplicationJobsClient) CancelThenPoll(ctx context.Context, id ReplicationJobId) error { + result, err := c.Cancel(ctx, id) + if err != nil { + return fmt.Errorf("performing Cancel: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Cancel: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_export.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_export.go new file mode 100644 index 00000000000..3744e562e2d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_export.go @@ -0,0 +1,75 @@ +package replicationjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExportOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// Export ... +func (c ReplicationJobsClient) Export(ctx context.Context, id VaultId, input JobQueryParameter) (result ExportOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/replicationJobs/export", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ExportThenPoll performs Export then polls until it's completed +func (c ReplicationJobsClient) ExportThenPoll(ctx context.Context, id VaultId, input JobQueryParameter) error { + result, err := c.Export(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Export: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Export: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_get.go new file mode 100644 index 00000000000..87300753784 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_get.go @@ -0,0 +1,53 @@ +package replicationjobs + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Job +} + +// Get ... +func (c ReplicationJobsClient) Get(ctx context.Context, id ReplicationJobId) (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 Job + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_list.go new file mode 100644 index 00000000000..2ff295118f8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_list.go @@ -0,0 +1,134 @@ +package replicationjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]Job +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Job +} + +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 ReplicationJobsClient) List(ctx context.Context, id VaultId, 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/replicationJobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Job `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 ReplicationJobsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, JobOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationJobsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate JobOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Job, 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/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_restart.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_restart.go new file mode 100644 index 00000000000..2750aec1de9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_restart.go @@ -0,0 +1,71 @@ +package replicationjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// Restart ... +func (c ReplicationJobsClient) Restart(ctx context.Context, id ReplicationJobId) (result RestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestartThenPoll performs Restart then polls until it's completed +func (c ReplicationJobsClient) RestartThenPoll(ctx context.Context, id ReplicationJobId) error { + result, err := c.Restart(ctx, id) + if err != nil { + return fmt.Errorf("performing Restart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restart: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_resume.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_resume.go new file mode 100644 index 00000000000..1470fd97f41 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/method_resume.go @@ -0,0 +1,75 @@ +package replicationjobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Job +} + +// Resume ... +func (c ReplicationJobsClient) Resume(ctx context.Context, id ReplicationJobId, input ResumeJobParams) (result ResumeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resume", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.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 ReplicationJobsClient) ResumeThenPoll(ctx context.Context, id ReplicationJobId, input ResumeJobParams) error { + result, err := c.Resume(ctx, id, input) + 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/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_asrjobdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_asrjobdetails.go new file mode 100644 index 00000000000..7f4aa5f741b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_asrjobdetails.go @@ -0,0 +1,51 @@ +package replicationjobs + +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 _ JobDetails = AsrJobDetails{} + +type AsrJobDetails struct { + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s AsrJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = AsrJobDetails{} + +func (s AsrJobDetails) MarshalJSON() ([]byte, error) { + type wrapper AsrJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AsrJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AsrJobDetails: %+v", err) + } + + decoded["instanceType"] = "AsrJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AsrJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_asrtask.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_asrtask.go new file mode 100644 index 00000000000..5088e2dc807 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_asrtask.go @@ -0,0 +1,105 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" + "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 ASRTask struct { + AllowedActions *[]string `json:"allowedActions,omitempty"` + CustomDetails TaskTypeDetails `json:"customDetails"` + EndTime *string `json:"endTime,omitempty"` + Errors *[]JobErrorDetails `json:"errors,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + GroupTaskCustomDetails GroupTaskDetails `json:"groupTaskCustomDetails"` + Name *string `json:"name,omitempty"` + StartTime *string `json:"startTime,omitempty"` + State *string `json:"state,omitempty"` + StateDescription *string `json:"stateDescription,omitempty"` + TaskId *string `json:"taskId,omitempty"` + TaskType *string `json:"taskType,omitempty"` +} + +func (o *ASRTask) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ASRTask) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *ASRTask) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ASRTask) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Unmarshaler = &ASRTask{} + +func (s *ASRTask) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AllowedActions *[]string `json:"allowedActions,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Errors *[]JobErrorDetails `json:"errors,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Name *string `json:"name,omitempty"` + StartTime *string `json:"startTime,omitempty"` + State *string `json:"state,omitempty"` + StateDescription *string `json:"stateDescription,omitempty"` + TaskId *string `json:"taskId,omitempty"` + TaskType *string `json:"taskType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AllowedActions = decoded.AllowedActions + s.EndTime = decoded.EndTime + s.Errors = decoded.Errors + s.FriendlyName = decoded.FriendlyName + s.Name = decoded.Name + s.StartTime = decoded.StartTime + s.State = decoded.State + s.StateDescription = decoded.StateDescription + s.TaskId = decoded.TaskId + s.TaskType = decoded.TaskType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ASRTask into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := UnmarshalTaskTypeDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'ASRTask': %+v", err) + } + s.CustomDetails = impl + } + + if v, ok := temp["groupTaskCustomDetails"]; ok { + impl, err := UnmarshalGroupTaskDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'GroupTaskCustomDetails' for 'ASRTask': %+v", err) + } + s.GroupTaskCustomDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_automationrunbooktaskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_automationrunbooktaskdetails.go new file mode 100644 index 00000000000..8e3ea451afe --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_automationrunbooktaskdetails.go @@ -0,0 +1,58 @@ +package replicationjobs + +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 _ TaskTypeDetails = AutomationRunbookTaskDetails{} + +type AutomationRunbookTaskDetails struct { + AccountName *string `json:"accountName,omitempty"` + CloudServiceName *string `json:"cloudServiceName,omitempty"` + IsPrimarySideScript *bool `json:"isPrimarySideScript,omitempty"` + JobId *string `json:"jobId,omitempty"` + JobOutput *string `json:"jobOutput,omitempty"` + Name *string `json:"name,omitempty"` + RunbookId *string `json:"runbookId,omitempty"` + RunbookName *string `json:"runbookName,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s AutomationRunbookTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = AutomationRunbookTaskDetails{} + +func (s AutomationRunbookTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper AutomationRunbookTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutomationRunbookTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutomationRunbookTaskDetails: %+v", err) + } + + decoded["instanceType"] = "AutomationRunbookTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutomationRunbookTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_clusterfailoverjobdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_clusterfailoverjobdetails.go new file mode 100644 index 00000000000..e7e4b56cb58 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_clusterfailoverjobdetails.go @@ -0,0 +1,52 @@ +package replicationjobs + +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 _ JobDetails = ClusterFailoverJobDetails{} + +type ClusterFailoverJobDetails struct { + ProtectedItemDetails *[]FailoverReplicationProtectedItemDetails `json:"protectedItemDetails,omitempty"` + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s ClusterFailoverJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ClusterFailoverJobDetails{} + +func (s ClusterFailoverJobDetails) MarshalJSON() ([]byte, error) { + type wrapper ClusterFailoverJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ClusterFailoverJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ClusterFailoverJobDetails: %+v", err) + } + + decoded["instanceType"] = "ClusterFailoverJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ClusterFailoverJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_clusterswitchprotectionjobdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_clusterswitchprotectionjobdetails.go new file mode 100644 index 00000000000..48238d85340 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_clusterswitchprotectionjobdetails.go @@ -0,0 +1,52 @@ +package replicationjobs + +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 _ JobDetails = ClusterSwitchProtectionJobDetails{} + +type ClusterSwitchProtectionJobDetails struct { + NewReplicationProtectionClusterId *string `json:"newReplicationProtectionClusterId,omitempty"` + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s ClusterSwitchProtectionJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ClusterSwitchProtectionJobDetails{} + +func (s ClusterSwitchProtectionJobDetails) MarshalJSON() ([]byte, error) { + type wrapper ClusterSwitchProtectionJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ClusterSwitchProtectionJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ClusterSwitchProtectionJobDetails: %+v", err) + } + + decoded["instanceType"] = "ClusterSwitchProtectionJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ClusterSwitchProtectionJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_clustertestfailoverjobdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_clustertestfailoverjobdetails.go new file mode 100644 index 00000000000..fd3d258a382 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_clustertestfailoverjobdetails.go @@ -0,0 +1,57 @@ +package replicationjobs + +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 _ JobDetails = ClusterTestFailoverJobDetails{} + +type ClusterTestFailoverJobDetails struct { + Comments *string `json:"comments,omitempty"` + NetworkFriendlyName *string `json:"networkFriendlyName,omitempty"` + NetworkName *string `json:"networkName,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + ProtectedItemDetails *[]FailoverReplicationProtectedItemDetails `json:"protectedItemDetails,omitempty"` + TestFailoverStatus *string `json:"testFailoverStatus,omitempty"` + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s ClusterTestFailoverJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ClusterTestFailoverJobDetails{} + +func (s ClusterTestFailoverJobDetails) MarshalJSON() ([]byte, error) { + type wrapper ClusterTestFailoverJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ClusterTestFailoverJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ClusterTestFailoverJobDetails: %+v", err) + } + + decoded["instanceType"] = "ClusterTestFailoverJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ClusterTestFailoverJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_consistencychecktaskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_consistencychecktaskdetails.go new file mode 100644 index 00000000000..4e945c5c362 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_consistencychecktaskdetails.go @@ -0,0 +1,50 @@ +package replicationjobs + +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 _ TaskTypeDetails = ConsistencyCheckTaskDetails{} + +type ConsistencyCheckTaskDetails struct { + VMDetails *[]InconsistentVMDetails `json:"vmDetails,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s ConsistencyCheckTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ConsistencyCheckTaskDetails{} + +func (s ConsistencyCheckTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper ConsistencyCheckTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ConsistencyCheckTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ConsistencyCheckTaskDetails: %+v", err) + } + + decoded["instanceType"] = "ConsistencyCheckTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ConsistencyCheckTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_exportjobdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_exportjobdetails.go new file mode 100644 index 00000000000..4f6a728cb67 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_exportjobdetails.go @@ -0,0 +1,53 @@ +package replicationjobs + +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 _ JobDetails = ExportJobDetails{} + +type ExportJobDetails struct { + BlobUri *string `json:"blobUri,omitempty"` + SasToken *string `json:"sasToken,omitempty"` + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s ExportJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ExportJobDetails{} + +func (s ExportJobDetails) MarshalJSON() ([]byte, error) { + type wrapper ExportJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExportJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExportJobDetails: %+v", err) + } + + decoded["instanceType"] = "ExportJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExportJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_fabricreplicationgrouptaskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_fabricreplicationgrouptaskdetails.go new file mode 100644 index 00000000000..9c64ad0db35 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_fabricreplicationgrouptaskdetails.go @@ -0,0 +1,51 @@ +package replicationjobs + +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 _ TaskTypeDetails = FabricReplicationGroupTaskDetails{} + +type FabricReplicationGroupTaskDetails struct { + SkippedReason *string `json:"skippedReason,omitempty"` + SkippedReasonString *string `json:"skippedReasonString,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s FabricReplicationGroupTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = FabricReplicationGroupTaskDetails{} + +func (s FabricReplicationGroupTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper FabricReplicationGroupTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FabricReplicationGroupTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FabricReplicationGroupTaskDetails: %+v", err) + } + + decoded["instanceType"] = "FabricReplicationGroupTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FabricReplicationGroupTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_failoverjobdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_failoverjobdetails.go new file mode 100644 index 00000000000..512eb079845 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_failoverjobdetails.go @@ -0,0 +1,52 @@ +package replicationjobs + +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 _ JobDetails = FailoverJobDetails{} + +type FailoverJobDetails struct { + ProtectedItemDetails *[]FailoverReplicationProtectedItemDetails `json:"protectedItemDetails,omitempty"` + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s FailoverJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = FailoverJobDetails{} + +func (s FailoverJobDetails) MarshalJSON() ([]byte, error) { + type wrapper FailoverJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FailoverJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FailoverJobDetails: %+v", err) + } + + decoded["instanceType"] = "FailoverJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FailoverJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_failoverreplicationprotecteditemdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_failoverreplicationprotecteditemdetails.go new file mode 100644 index 00000000000..8f28aeba2ed --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_failoverreplicationprotecteditemdetails.go @@ -0,0 +1,34 @@ +package replicationjobs + +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 FailoverReplicationProtectedItemDetails struct { + FriendlyName *string `json:"friendlyName,omitempty"` + Name *string `json:"name,omitempty"` + NetworkConnectionStatus *string `json:"networkConnectionStatus,omitempty"` + NetworkFriendlyName *string `json:"networkFriendlyName,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + Subnet *string `json:"subnet,omitempty"` + TestVMFriendlyName *string `json:"testVmFriendlyName,omitempty"` + TestVMName *string `json:"testVmName,omitempty"` +} + +func (o *FailoverReplicationProtectedItemDetails) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *FailoverReplicationProtectedItemDetails) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_grouptaskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_grouptaskdetails.go new file mode 100644 index 00000000000..60467655c21 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_grouptaskdetails.go @@ -0,0 +1,84 @@ +package replicationjobs + +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 GroupTaskDetails interface { + GroupTaskDetails() BaseGroupTaskDetailsImpl +} + +var _ GroupTaskDetails = BaseGroupTaskDetailsImpl{} + +type BaseGroupTaskDetailsImpl struct { + ChildTasks *[]ASRTask `json:"childTasks,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s BaseGroupTaskDetailsImpl) GroupTaskDetails() BaseGroupTaskDetailsImpl { + return s +} + +var _ GroupTaskDetails = RawGroupTaskDetailsImpl{} + +// RawGroupTaskDetailsImpl 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 RawGroupTaskDetailsImpl struct { + groupTaskDetails BaseGroupTaskDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawGroupTaskDetailsImpl) GroupTaskDetails() BaseGroupTaskDetailsImpl { + return s.groupTaskDetails +} + +func UnmarshalGroupTaskDetailsImplementation(input []byte) (GroupTaskDetails, 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 GroupTaskDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "InlineWorkflowTaskDetails") { + var out InlineWorkflowTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InlineWorkflowTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RecoveryPlanGroupTaskDetails") { + var out RecoveryPlanGroupTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanGroupTaskDetails: %+v", err) + } + return out, nil + } + + var parent BaseGroupTaskDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseGroupTaskDetailsImpl: %+v", err) + } + + return RawGroupTaskDetailsImpl{ + groupTaskDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_inconsistentvmdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_inconsistentvmdetails.go new file mode 100644 index 00000000000..04192118e25 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_inconsistentvmdetails.go @@ -0,0 +1,11 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InconsistentVMDetails struct { + CloudName *string `json:"cloudName,omitempty"` + Details *[]string `json:"details,omitempty"` + ErrorIds *[]string `json:"errorIds,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_inlineworkflowtaskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_inlineworkflowtaskdetails.go new file mode 100644 index 00000000000..dc281023cd2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_inlineworkflowtaskdetails.go @@ -0,0 +1,52 @@ +package replicationjobs + +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 _ GroupTaskDetails = InlineWorkflowTaskDetails{} + +type InlineWorkflowTaskDetails struct { + WorkflowIds *[]string `json:"workflowIds,omitempty"` + + // Fields inherited from GroupTaskDetails + + ChildTasks *[]ASRTask `json:"childTasks,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s InlineWorkflowTaskDetails) GroupTaskDetails() BaseGroupTaskDetailsImpl { + return BaseGroupTaskDetailsImpl{ + ChildTasks: s.ChildTasks, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InlineWorkflowTaskDetails{} + +func (s InlineWorkflowTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper InlineWorkflowTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InlineWorkflowTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InlineWorkflowTaskDetails: %+v", err) + } + + decoded["instanceType"] = "InlineWorkflowTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InlineWorkflowTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_job.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_job.go new file mode 100644 index 00000000000..74a9debce1f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_job.go @@ -0,0 +1,12 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Job struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *JobProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobdetails.go new file mode 100644 index 00000000000..ea3d4d26d8f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobdetails.go @@ -0,0 +1,132 @@ +package replicationjobs + +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 JobDetails interface { + JobDetails() BaseJobDetailsImpl +} + +var _ JobDetails = BaseJobDetailsImpl{} + +type BaseJobDetailsImpl struct { + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s BaseJobDetailsImpl) JobDetails() BaseJobDetailsImpl { + return s +} + +var _ JobDetails = RawJobDetailsImpl{} + +// RawJobDetailsImpl 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 RawJobDetailsImpl struct { + jobDetails BaseJobDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawJobDetailsImpl) JobDetails() BaseJobDetailsImpl { + return s.jobDetails +} + +func UnmarshalJobDetailsImplementation(input []byte) (JobDetails, 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 JobDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AsrJobDetails") { + var out AsrJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AsrJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ClusterFailoverJobDetails") { + var out ClusterFailoverJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ClusterFailoverJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ClusterSwitchProtectionJobDetails") { + var out ClusterSwitchProtectionJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ClusterSwitchProtectionJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ClusterTestFailoverJobDetails") { + var out ClusterTestFailoverJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ClusterTestFailoverJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ExportJobDetails") { + var out ExportJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExportJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "FailoverJobDetails") { + var out FailoverJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FailoverJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SwitchProtectionJobDetails") { + var out SwitchProtectionJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SwitchProtectionJobDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TestFailoverJobDetails") { + var out TestFailoverJobDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TestFailoverJobDetails: %+v", err) + } + return out, nil + } + + var parent BaseJobDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseJobDetailsImpl: %+v", err) + } + + return RawJobDetailsImpl{ + jobDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobentity.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobentity.go new file mode 100644 index 00000000000..e3cbaea444e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobentity.go @@ -0,0 +1,13 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobEntity struct { + JobFriendlyName *string `json:"jobFriendlyName,omitempty"` + JobId *string `json:"jobId,omitempty"` + JobScenarioName *string `json:"jobScenarioName,omitempty"` + TargetInstanceType *string `json:"targetInstanceType,omitempty"` + TargetObjectId *string `json:"targetObjectId,omitempty"` + TargetObjectName *string `json:"targetObjectName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_joberrordetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_joberrordetails.go new file mode 100644 index 00000000000..797e2dc1bd1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_joberrordetails.go @@ -0,0 +1,30 @@ +package replicationjobs + +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 JobErrorDetails struct { + CreationTime *string `json:"creationTime,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ProviderErrorDetails *ProviderError `json:"providerErrorDetails,omitempty"` + ServiceErrorDetails *ServiceError `json:"serviceErrorDetails,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *JobErrorDetails) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *JobErrorDetails) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobproperties.go new file mode 100644 index 00000000000..a63dbf5d5f9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobproperties.go @@ -0,0 +1,105 @@ +package replicationjobs + +import ( + "encoding/json" + "fmt" + "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 JobProperties struct { + ActivityId *string `json:"activityId,omitempty"` + AllowedActions *[]string `json:"allowedActions,omitempty"` + CustomDetails JobDetails `json:"customDetails"` + EndTime *string `json:"endTime,omitempty"` + Errors *[]JobErrorDetails `json:"errors,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StartTime *string `json:"startTime,omitempty"` + State *string `json:"state,omitempty"` + StateDescription *string `json:"stateDescription,omitempty"` + TargetInstanceType *string `json:"targetInstanceType,omitempty"` + TargetObjectId *string `json:"targetObjectId,omitempty"` + TargetObjectName *string `json:"targetObjectName,omitempty"` + Tasks *[]ASRTask `json:"tasks,omitempty"` +} + +func (o *JobProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *JobProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *JobProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *JobProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Unmarshaler = &JobProperties{} + +func (s *JobProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ActivityId *string `json:"activityId,omitempty"` + AllowedActions *[]string `json:"allowedActions,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Errors *[]JobErrorDetails `json:"errors,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StartTime *string `json:"startTime,omitempty"` + State *string `json:"state,omitempty"` + StateDescription *string `json:"stateDescription,omitempty"` + TargetInstanceType *string `json:"targetInstanceType,omitempty"` + TargetObjectId *string `json:"targetObjectId,omitempty"` + TargetObjectName *string `json:"targetObjectName,omitempty"` + Tasks *[]ASRTask `json:"tasks,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ActivityId = decoded.ActivityId + s.AllowedActions = decoded.AllowedActions + s.EndTime = decoded.EndTime + s.Errors = decoded.Errors + s.FriendlyName = decoded.FriendlyName + s.ScenarioName = decoded.ScenarioName + s.StartTime = decoded.StartTime + s.State = decoded.State + s.StateDescription = decoded.StateDescription + s.TargetInstanceType = decoded.TargetInstanceType + s.TargetObjectId = decoded.TargetObjectId + s.TargetObjectName = decoded.TargetObjectName + s.Tasks = decoded.Tasks + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling JobProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := UnmarshalJobDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'JobProperties': %+v", err) + } + s.CustomDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobqueryparameter.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobqueryparameter.go new file mode 100644 index 00000000000..bc10a6b6e1d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobqueryparameter.go @@ -0,0 +1,15 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobQueryParameter struct { + AffectedObjectTypes *string `json:"affectedObjectTypes,omitempty"` + EndTime *string `json:"endTime,omitempty"` + FabricId *string `json:"fabricId,omitempty"` + JobName *string `json:"jobName,omitempty"` + JobOutputType *ExportJobOutputSerializationType `json:"jobOutputType,omitempty"` + JobStatus *string `json:"jobStatus,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimezoneOffset *float64 `json:"timezoneOffset,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobtaskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobtaskdetails.go new file mode 100644 index 00000000000..3ef70d2bc39 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_jobtaskdetails.go @@ -0,0 +1,50 @@ +package replicationjobs + +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 _ TaskTypeDetails = JobTaskDetails{} + +type JobTaskDetails struct { + JobTask *JobEntity `json:"jobTask,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s JobTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = JobTaskDetails{} + +func (s JobTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper JobTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling JobTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling JobTaskDetails: %+v", err) + } + + decoded["instanceType"] = "JobTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling JobTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_manualactiontaskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_manualactiontaskdetails.go new file mode 100644 index 00000000000..6b274494184 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_manualactiontaskdetails.go @@ -0,0 +1,52 @@ +package replicationjobs + +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 _ TaskTypeDetails = ManualActionTaskDetails{} + +type ManualActionTaskDetails struct { + Instructions *string `json:"instructions,omitempty"` + Name *string `json:"name,omitempty"` + Observation *string `json:"observation,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s ManualActionTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ManualActionTaskDetails{} + +func (s ManualActionTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper ManualActionTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ManualActionTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ManualActionTaskDetails: %+v", err) + } + + decoded["instanceType"] = "ManualActionTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ManualActionTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_providererror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_providererror.go new file mode 100644 index 00000000000..e7f3a6131ee --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_providererror.go @@ -0,0 +1,12 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderError struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_recoveryplangrouptaskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_recoveryplangrouptaskdetails.go new file mode 100644 index 00000000000..6eab9e8093b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_recoveryplangrouptaskdetails.go @@ -0,0 +1,54 @@ +package replicationjobs + +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 _ GroupTaskDetails = RecoveryPlanGroupTaskDetails{} + +type RecoveryPlanGroupTaskDetails struct { + GroupId *string `json:"groupId,omitempty"` + Name *string `json:"name,omitempty"` + RpGroupType *string `json:"rpGroupType,omitempty"` + + // Fields inherited from GroupTaskDetails + + ChildTasks *[]ASRTask `json:"childTasks,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanGroupTaskDetails) GroupTaskDetails() BaseGroupTaskDetailsImpl { + return BaseGroupTaskDetailsImpl{ + ChildTasks: s.ChildTasks, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanGroupTaskDetails{} + +func (s RecoveryPlanGroupTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanGroupTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanGroupTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanGroupTaskDetails: %+v", err) + } + + decoded["instanceType"] = "RecoveryPlanGroupTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanGroupTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_recoveryplanshutdowngrouptaskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_recoveryplanshutdowngrouptaskdetails.go new file mode 100644 index 00000000000..cd81c6460c1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_recoveryplanshutdowngrouptaskdetails.go @@ -0,0 +1,51 @@ +package replicationjobs + +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 _ GroupTaskDetails = RecoveryPlanShutdownGroupTaskDetails{} + +type RecoveryPlanShutdownGroupTaskDetails struct { + + // Fields inherited from GroupTaskDetails + + ChildTasks *[]ASRTask `json:"childTasks,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanShutdownGroupTaskDetails) GroupTaskDetails() BaseGroupTaskDetailsImpl { + return BaseGroupTaskDetailsImpl{ + ChildTasks: s.ChildTasks, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanShutdownGroupTaskDetails{} + +func (s RecoveryPlanShutdownGroupTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanShutdownGroupTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanShutdownGroupTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanShutdownGroupTaskDetails: %+v", err) + } + + decoded["instanceType"] = "RecoveryPlanShutdownGroupTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanShutdownGroupTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_resumejobparams.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_resumejobparams.go new file mode 100644 index 00000000000..c247d0c303b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_resumejobparams.go @@ -0,0 +1,8 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumeJobParams struct { + Properties *ResumeJobParamsProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_resumejobparamsproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_resumejobparamsproperties.go new file mode 100644 index 00000000000..a4dc002b22b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_resumejobparamsproperties.go @@ -0,0 +1,8 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumeJobParamsProperties struct { + Comments *string `json:"comments,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_scriptactiontaskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_scriptactiontaskdetails.go new file mode 100644 index 00000000000..0c01efcc79a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_scriptactiontaskdetails.go @@ -0,0 +1,53 @@ +package replicationjobs + +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 _ TaskTypeDetails = ScriptActionTaskDetails{} + +type ScriptActionTaskDetails struct { + IsPrimarySideScript *bool `json:"isPrimarySideScript,omitempty"` + Name *string `json:"name,omitempty"` + Output *string `json:"output,omitempty"` + Path *string `json:"path,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s ScriptActionTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ScriptActionTaskDetails{} + +func (s ScriptActionTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper ScriptActionTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ScriptActionTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ScriptActionTaskDetails: %+v", err) + } + + decoded["instanceType"] = "ScriptActionTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ScriptActionTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_serviceerror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_serviceerror.go new file mode 100644 index 00000000000..1ce1b446dc8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_serviceerror.go @@ -0,0 +1,12 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceError struct { + ActivityId *string `json:"activityId,omitempty"` + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_switchprotectionjobdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_switchprotectionjobdetails.go new file mode 100644 index 00000000000..396de18f8eb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_switchprotectionjobdetails.go @@ -0,0 +1,52 @@ +package replicationjobs + +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 _ JobDetails = SwitchProtectionJobDetails{} + +type SwitchProtectionJobDetails struct { + NewReplicationProtectedItemId *string `json:"newReplicationProtectedItemId,omitempty"` + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s SwitchProtectionJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = SwitchProtectionJobDetails{} + +func (s SwitchProtectionJobDetails) MarshalJSON() ([]byte, error) { + type wrapper SwitchProtectionJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SwitchProtectionJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SwitchProtectionJobDetails: %+v", err) + } + + decoded["instanceType"] = "SwitchProtectionJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SwitchProtectionJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_tasktypedetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_tasktypedetails.go new file mode 100644 index 00000000000..cf5e57d1cd3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_tasktypedetails.go @@ -0,0 +1,115 @@ +package replicationjobs + +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 TaskTypeDetails interface { + TaskTypeDetails() BaseTaskTypeDetailsImpl +} + +var _ TaskTypeDetails = BaseTaskTypeDetailsImpl{} + +type BaseTaskTypeDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseTaskTypeDetailsImpl) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return s +} + +var _ TaskTypeDetails = RawTaskTypeDetailsImpl{} + +// RawTaskTypeDetailsImpl 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 RawTaskTypeDetailsImpl struct { + taskTypeDetails BaseTaskTypeDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawTaskTypeDetailsImpl) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return s.taskTypeDetails +} + +func UnmarshalTaskTypeDetailsImplementation(input []byte) (TaskTypeDetails, 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 TaskTypeDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AutomationRunbookTaskDetails") { + var out AutomationRunbookTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutomationRunbookTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ConsistencyCheckTaskDetails") { + var out ConsistencyCheckTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ConsistencyCheckTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "JobTaskDetails") { + var out JobTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into JobTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ManualActionTaskDetails") { + var out ManualActionTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ManualActionTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ScriptActionTaskDetails") { + var out ScriptActionTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ScriptActionTaskDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmNicUpdatesTaskDetails") { + var out VMNicUpdatesTaskDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMNicUpdatesTaskDetails: %+v", err) + } + return out, nil + } + + var parent BaseTaskTypeDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseTaskTypeDetailsImpl: %+v", err) + } + + return RawTaskTypeDetailsImpl{ + taskTypeDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_testfailoverjobdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_testfailoverjobdetails.go new file mode 100644 index 00000000000..60e90887c9e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_testfailoverjobdetails.go @@ -0,0 +1,57 @@ +package replicationjobs + +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 _ JobDetails = TestFailoverJobDetails{} + +type TestFailoverJobDetails struct { + Comments *string `json:"comments,omitempty"` + NetworkFriendlyName *string `json:"networkFriendlyName,omitempty"` + NetworkName *string `json:"networkName,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + ProtectedItemDetails *[]FailoverReplicationProtectedItemDetails `json:"protectedItemDetails,omitempty"` + TestFailoverStatus *string `json:"testFailoverStatus,omitempty"` + + // Fields inherited from JobDetails + + AffectedObjectDetails *map[string]string `json:"affectedObjectDetails,omitempty"` + InstanceType string `json:"instanceType"` +} + +func (s TestFailoverJobDetails) JobDetails() BaseJobDetailsImpl { + return BaseJobDetailsImpl{ + AffectedObjectDetails: s.AffectedObjectDetails, + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = TestFailoverJobDetails{} + +func (s TestFailoverJobDetails) MarshalJSON() ([]byte, error) { + type wrapper TestFailoverJobDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TestFailoverJobDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TestFailoverJobDetails: %+v", err) + } + + decoded["instanceType"] = "TestFailoverJobDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TestFailoverJobDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_virtualmachinetaskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_virtualmachinetaskdetails.go new file mode 100644 index 00000000000..0bed7483e0a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_virtualmachinetaskdetails.go @@ -0,0 +1,51 @@ +package replicationjobs + +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 _ TaskTypeDetails = VirtualMachineTaskDetails{} + +type VirtualMachineTaskDetails struct { + SkippedReason *string `json:"skippedReason,omitempty"` + SkippedReasonString *string `json:"skippedReasonString,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s VirtualMachineTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VirtualMachineTaskDetails{} + +func (s VirtualMachineTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper VirtualMachineTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VirtualMachineTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VirtualMachineTaskDetails: %+v", err) + } + + decoded["instanceType"] = "VirtualMachineTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VirtualMachineTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_vmnicupdatestaskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_vmnicupdatestaskdetails.go new file mode 100644 index 00000000000..e20168ec669 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/model_vmnicupdatestaskdetails.go @@ -0,0 +1,52 @@ +package replicationjobs + +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 _ TaskTypeDetails = VMNicUpdatesTaskDetails{} + +type VMNicUpdatesTaskDetails struct { + Name *string `json:"name,omitempty"` + NicId *string `json:"nicId,omitempty"` + VMId *string `json:"vmId,omitempty"` + + // Fields inherited from TaskTypeDetails + + InstanceType string `json:"instanceType"` +} + +func (s VMNicUpdatesTaskDetails) TaskTypeDetails() BaseTaskTypeDetailsImpl { + return BaseTaskTypeDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMNicUpdatesTaskDetails{} + +func (s VMNicUpdatesTaskDetails) MarshalJSON() ([]byte, error) { + type wrapper VMNicUpdatesTaskDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMNicUpdatesTaskDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMNicUpdatesTaskDetails: %+v", err) + } + + decoded["instanceType"] = "VmNicUpdatesTaskDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMNicUpdatesTaskDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/predicates.go new file mode 100644 index 00000000000..840f78ec8e3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/predicates.go @@ -0,0 +1,32 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p JobOperationPredicate) Matches(input Job) 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/recoveryservicessiterecovery/2025-02-01/replicationjobs/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/version.go new file mode 100644 index 00000000000..3d218594042 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationjobs/version.go @@ -0,0 +1,10 @@ +package replicationjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationjobs/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/README.md new file mode 100644 index 00000000000..a42550982c0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks` Documentation + +The `replicationlogicalnetworks` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks" +``` + + +### Client Initialization + +```go +client := replicationlogicalnetworks.NewReplicationLogicalNetworksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationLogicalNetworksClient.Get` + +```go +ctx := context.TODO() +id := replicationlogicalnetworks.NewReplicationLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationLogicalNetworkName") + +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: `ReplicationLogicalNetworksClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationlogicalnetworks.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/client.go new file mode 100644 index 00000000000..c3f18b03d72 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/client.go @@ -0,0 +1,26 @@ +package replicationlogicalnetworks + +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 ReplicationLogicalNetworksClient struct { + Client *resourcemanager.Client +} + +func NewReplicationLogicalNetworksClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationLogicalNetworksClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationlogicalnetworks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationLogicalNetworksClient: %+v", err) + } + + return &ReplicationLogicalNetworksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/id_replicationfabric.go new file mode 100644 index 00000000000..cd151e6011f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/id_replicationfabric.go @@ -0,0 +1,139 @@ +package replicationlogicalnetworks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationFabricId{}) +} + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/id_replicationfabric_test.go new file mode 100644 index 00000000000..09d32c71688 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationlogicalnetworks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/id_replicationlogicalnetwork.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/id_replicationlogicalnetwork.go new file mode 100644 index 00000000000..7f9fd6f74ba --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/id_replicationlogicalnetwork.go @@ -0,0 +1,148 @@ +package replicationlogicalnetworks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationLogicalNetworkId{}) +} + +var _ resourceids.ResourceId = &ReplicationLogicalNetworkId{} + +// ReplicationLogicalNetworkId is a struct representing the Resource ID for a Replication Logical Network +type ReplicationLogicalNetworkId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationLogicalNetworkName string +} + +// NewReplicationLogicalNetworkID returns a new ReplicationLogicalNetworkId struct +func NewReplicationLogicalNetworkID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationLogicalNetworkName string) ReplicationLogicalNetworkId { + return ReplicationLogicalNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationLogicalNetworkName: replicationLogicalNetworkName, + } +} + +// ParseReplicationLogicalNetworkID parses 'input' into a ReplicationLogicalNetworkId +func ParseReplicationLogicalNetworkID(input string) (*ReplicationLogicalNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationLogicalNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationLogicalNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationLogicalNetworkIDInsensitively parses 'input' case-insensitively into a ReplicationLogicalNetworkId +// note: this method should only be used for API response data and not user input +func ParseReplicationLogicalNetworkIDInsensitively(input string) (*ReplicationLogicalNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationLogicalNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationLogicalNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationLogicalNetworkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationLogicalNetworkName, ok = input.Parsed["replicationLogicalNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationLogicalNetworkName", input) + } + + return nil +} + +// ValidateReplicationLogicalNetworkID checks that 'input' can be parsed as a Replication Logical Network ID +func ValidateReplicationLogicalNetworkID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationLogicalNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Logical Network ID +func (id ReplicationLogicalNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationLogicalNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationLogicalNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Logical Network ID +func (id ReplicationLogicalNetworkId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationLogicalNetworks", "replicationLogicalNetworks", "replicationLogicalNetworks"), + resourceids.UserSpecifiedSegment("replicationLogicalNetworkName", "replicationLogicalNetworkName"), + } +} + +// String returns a human-readable description of this Replication Logical Network ID +func (id ReplicationLogicalNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Logical Network Name: %q", id.ReplicationLogicalNetworkName), + } + return fmt.Sprintf("Replication Logical Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/id_replicationlogicalnetwork_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/id_replicationlogicalnetwork_test.go new file mode 100644 index 00000000000..d0a55e18453 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/id_replicationlogicalnetwork_test.go @@ -0,0 +1,372 @@ +package replicationlogicalnetworks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationLogicalNetworkId{} + +func TestNewReplicationLogicalNetworkID(t *testing.T) { + id := NewReplicationLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationLogicalNetworkName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationLogicalNetworkName != "replicationLogicalNetworkName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationLogicalNetworkName'", id.ReplicationLogicalNetworkName, "replicationLogicalNetworkName") + } +} + +func TestFormatReplicationLogicalNetworkID(t *testing.T) { + actual := NewReplicationLogicalNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationLogicalNetworkName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationLogicalNetworks/replicationLogicalNetworkName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationLogicalNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationLogicalNetworkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationLogicalNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationLogicalNetworks/replicationLogicalNetworkName", + Expected: &ReplicationLogicalNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationLogicalNetworkName: "replicationLogicalNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationLogicalNetworks/replicationLogicalNetworkName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationLogicalNetworkID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationLogicalNetworkName != v.Expected.ReplicationLogicalNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationLogicalNetworkName", v.Expected.ReplicationLogicalNetworkName, actual.ReplicationLogicalNetworkName) + } + + } +} + +func TestParseReplicationLogicalNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationLogicalNetworkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationLogicalNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnLoGiCaLnEtWoRkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationLogicalNetworks/replicationLogicalNetworkName", + Expected: &ReplicationLogicalNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationLogicalNetworkName: "replicationLogicalNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationLogicalNetworks/replicationLogicalNetworkName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnLoGiCaLnEtWoRkS/rEpLiCaTiOnLoGiCaLnEtWoRkNaMe", + Expected: &ReplicationLogicalNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationLogicalNetworkName: "rEpLiCaTiOnLoGiCaLnEtWoRkNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnLoGiCaLnEtWoRkS/rEpLiCaTiOnLoGiCaLnEtWoRkNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationLogicalNetworkIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationLogicalNetworkName != v.Expected.ReplicationLogicalNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationLogicalNetworkName", v.Expected.ReplicationLogicalNetworkName, actual.ReplicationLogicalNetworkName) + } + + } +} + +func TestSegmentsForReplicationLogicalNetworkId(t *testing.T) { + segments := ReplicationLogicalNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationLogicalNetworkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/method_get.go new file mode 100644 index 00000000000..c6334546f1e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/method_get.go @@ -0,0 +1,53 @@ +package replicationlogicalnetworks + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *LogicalNetwork +} + +// Get ... +func (c ReplicationLogicalNetworksClient) Get(ctx context.Context, id ReplicationLogicalNetworkId) (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 LogicalNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..e9fef6356f3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/method_listbyreplicationfabrics.go @@ -0,0 +1,105 @@ +package replicationlogicalnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LogicalNetwork +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []LogicalNetwork +} + +type ListByReplicationFabricsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationFabricsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationFabrics ... +func (c ReplicationLogicalNetworksClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationFabricsCustomPager{}, + Path: fmt.Sprintf("%s/replicationLogicalNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LogicalNetwork `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationLogicalNetworksClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, LogicalNetworkOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationLogicalNetworksClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate LogicalNetworkOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]LogicalNetwork, 0) + + resp, err := c.ListByReplicationFabrics(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 = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/model_logicalnetwork.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/model_logicalnetwork.go new file mode 100644 index 00000000000..957182ab3db --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/model_logicalnetwork.go @@ -0,0 +1,12 @@ +package replicationlogicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetwork struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *LogicalNetworkProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/model_logicalnetworkproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/model_logicalnetworkproperties.go new file mode 100644 index 00000000000..2200c344760 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/model_logicalnetworkproperties.go @@ -0,0 +1,11 @@ +package replicationlogicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetworkProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + LogicalNetworkDefinitionsStatus *string `json:"logicalNetworkDefinitionsStatus,omitempty"` + LogicalNetworkUsage *string `json:"logicalNetworkUsage,omitempty"` + NetworkVirtualizationStatus *string `json:"networkVirtualizationStatus,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/predicates.go new file mode 100644 index 00000000000..30e71a8f92c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/predicates.go @@ -0,0 +1,32 @@ +package replicationlogicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogicalNetworkOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p LogicalNetworkOperationPredicate) Matches(input LogicalNetwork) 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/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/version.go new file mode 100644 index 00000000000..4e8a51bba6c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationlogicalnetworks/version.go @@ -0,0 +1,10 @@ +package replicationlogicalnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationlogicalnetworks/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/README.md new file mode 100644 index 00000000000..4da56bc74c3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/README.md @@ -0,0 +1,218 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems` Documentation + +The `replicationmigrationitems` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems" +``` + + +### Client Initialization + +```go +client := replicationmigrationitems.NewReplicationMigrationItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Create` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.EnableMigrationInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Delete` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +if err := client.DeleteThenPoll(ctx, id, replicationmigrationitems.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Get` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +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: `ReplicationMigrationItemsClient.List` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, replicationmigrationitems.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationmigrationitems.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.ListByReplicationProtectionContainers` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +// alternatively `client.ListByReplicationProtectionContainers(ctx, id, replicationmigrationitems.DefaultListByReplicationProtectionContainersOperationOptions())` can be used to do batched pagination +items, err := client.ListByReplicationProtectionContainersComplete(ctx, id, replicationmigrationitems.DefaultListByReplicationProtectionContainersOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Migrate` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.MigrateInput{ + // ... +} + + +if err := client.MigrateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.PauseReplication` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.PauseReplicationInput{ + // ... +} + + +if err := client.PauseReplicationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.ResumeReplication` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.ResumeReplicationInput{ + // ... +} + + +if err := client.ResumeReplicationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Resync` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.ResyncInput{ + // ... +} + + +if err := client.ResyncThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.TestMigrate` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.TestMigrateInput{ + // ... +} + + +if err := client.TestMigrateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.TestMigrateCleanup` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.TestMigrateCleanupInput{ + // ... +} + + +if err := client.TestMigrateCleanupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationMigrationItemsClient.Update` + +```go +ctx := context.TODO() +id := replicationmigrationitems.NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + +payload := replicationmigrationitems.UpdateMigrationItemInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/client.go new file mode 100644 index 00000000000..65aedf397c6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/client.go @@ -0,0 +1,26 @@ +package replicationmigrationitems + +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 ReplicationMigrationItemsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationMigrationItemsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationMigrationItemsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationmigrationitems", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationMigrationItemsClient: %+v", err) + } + + return &ReplicationMigrationItemsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/constants.go new file mode 100644 index 00000000000..b87ce8828c0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/constants.go @@ -0,0 +1,616 @@ +package replicationmigrationitems + +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 DiskAccountType string + +const ( + DiskAccountTypePremiumLRS DiskAccountType = "Premium_LRS" + DiskAccountTypePremiumVTwoLRS DiskAccountType = "PremiumV2_LRS" + DiskAccountTypePremiumZRS DiskAccountType = "Premium_ZRS" + DiskAccountTypeStandardLRS DiskAccountType = "Standard_LRS" + DiskAccountTypeStandardSSDLRS DiskAccountType = "StandardSSD_LRS" + DiskAccountTypeStandardSSDZRS DiskAccountType = "StandardSSD_ZRS" + DiskAccountTypeUltraSSDLRS DiskAccountType = "UltraSSD_LRS" +) + +func PossibleValuesForDiskAccountType() []string { + return []string{ + string(DiskAccountTypePremiumLRS), + string(DiskAccountTypePremiumVTwoLRS), + string(DiskAccountTypePremiumZRS), + string(DiskAccountTypeStandardLRS), + string(DiskAccountTypeStandardSSDLRS), + string(DiskAccountTypeStandardSSDZRS), + string(DiskAccountTypeUltraSSDLRS), + } +} + +func (s *DiskAccountType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskAccountType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskAccountType(input string) (*DiskAccountType, error) { + vals := map[string]DiskAccountType{ + "premium_lrs": DiskAccountTypePremiumLRS, + "premiumv2_lrs": DiskAccountTypePremiumVTwoLRS, + "premium_zrs": DiskAccountTypePremiumZRS, + "standard_lrs": DiskAccountTypeStandardLRS, + "standardssd_lrs": DiskAccountTypeStandardSSDLRS, + "standardssd_zrs": DiskAccountTypeStandardSSDZRS, + "ultrassd_lrs": DiskAccountTypeUltraSSDLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskAccountType(input) + return &out, nil +} + +type EthernetAddressType string + +const ( + EthernetAddressTypeDynamic EthernetAddressType = "Dynamic" + EthernetAddressTypeStatic EthernetAddressType = "Static" +) + +func PossibleValuesForEthernetAddressType() []string { + return []string{ + string(EthernetAddressTypeDynamic), + string(EthernetAddressTypeStatic), + } +} + +func (s *EthernetAddressType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEthernetAddressType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEthernetAddressType(input string) (*EthernetAddressType, error) { + vals := map[string]EthernetAddressType{ + "dynamic": EthernetAddressTypeDynamic, + "static": EthernetAddressTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EthernetAddressType(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type LicenseType string + +const ( + LicenseTypeNoLicenseType LicenseType = "NoLicenseType" + LicenseTypeNotSpecified LicenseType = "NotSpecified" + LicenseTypeWindowsServer LicenseType = "WindowsServer" +) + +func PossibleValuesForLicenseType() []string { + return []string{ + string(LicenseTypeNoLicenseType), + string(LicenseTypeNotSpecified), + string(LicenseTypeWindowsServer), + } +} + +func (s *LicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLicenseType(input string) (*LicenseType, error) { + vals := map[string]LicenseType{ + "nolicensetype": LicenseTypeNoLicenseType, + "notspecified": LicenseTypeNotSpecified, + "windowsserver": LicenseTypeWindowsServer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LicenseType(input) + return &out, nil +} + +type LinuxLicenseType string + +const ( + LinuxLicenseTypeLinuxServer LinuxLicenseType = "LinuxServer" + LinuxLicenseTypeNoLicenseType LinuxLicenseType = "NoLicenseType" + LinuxLicenseTypeNotSpecified LinuxLicenseType = "NotSpecified" +) + +func PossibleValuesForLinuxLicenseType() []string { + return []string{ + string(LinuxLicenseTypeLinuxServer), + string(LinuxLicenseTypeNoLicenseType), + string(LinuxLicenseTypeNotSpecified), + } +} + +func (s *LinuxLicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLinuxLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLinuxLicenseType(input string) (*LinuxLicenseType, error) { + vals := map[string]LinuxLicenseType{ + "linuxserver": LinuxLicenseTypeLinuxServer, + "nolicensetype": LinuxLicenseTypeNoLicenseType, + "notspecified": LinuxLicenseTypeNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LinuxLicenseType(input) + return &out, nil +} + +type MigrationItemOperation string + +const ( + MigrationItemOperationDisableMigration MigrationItemOperation = "DisableMigration" + MigrationItemOperationMigrate MigrationItemOperation = "Migrate" + MigrationItemOperationPauseReplication MigrationItemOperation = "PauseReplication" + MigrationItemOperationResumeReplication MigrationItemOperation = "ResumeReplication" + MigrationItemOperationStartResync MigrationItemOperation = "StartResync" + MigrationItemOperationTestMigrate MigrationItemOperation = "TestMigrate" + MigrationItemOperationTestMigrateCleanup MigrationItemOperation = "TestMigrateCleanup" +) + +func PossibleValuesForMigrationItemOperation() []string { + return []string{ + string(MigrationItemOperationDisableMigration), + string(MigrationItemOperationMigrate), + string(MigrationItemOperationPauseReplication), + string(MigrationItemOperationResumeReplication), + string(MigrationItemOperationStartResync), + string(MigrationItemOperationTestMigrate), + string(MigrationItemOperationTestMigrateCleanup), + } +} + +func (s *MigrationItemOperation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMigrationItemOperation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMigrationItemOperation(input string) (*MigrationItemOperation, error) { + vals := map[string]MigrationItemOperation{ + "disablemigration": MigrationItemOperationDisableMigration, + "migrate": MigrationItemOperationMigrate, + "pausereplication": MigrationItemOperationPauseReplication, + "resumereplication": MigrationItemOperationResumeReplication, + "startresync": MigrationItemOperationStartResync, + "testmigrate": MigrationItemOperationTestMigrate, + "testmigratecleanup": MigrationItemOperationTestMigrateCleanup, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MigrationItemOperation(input) + return &out, nil +} + +type MigrationState string + +const ( + MigrationStateDisableMigrationFailed MigrationState = "DisableMigrationFailed" + MigrationStateDisableMigrationInProgress MigrationState = "DisableMigrationInProgress" + MigrationStateEnableMigrationFailed MigrationState = "EnableMigrationFailed" + MigrationStateEnableMigrationInProgress MigrationState = "EnableMigrationInProgress" + MigrationStateInitialSeedingFailed MigrationState = "InitialSeedingFailed" + MigrationStateInitialSeedingInProgress MigrationState = "InitialSeedingInProgress" + MigrationStateMigrationCompletedWithInformation MigrationState = "MigrationCompletedWithInformation" + MigrationStateMigrationFailed MigrationState = "MigrationFailed" + MigrationStateMigrationInProgress MigrationState = "MigrationInProgress" + MigrationStateMigrationPartiallySucceeded MigrationState = "MigrationPartiallySucceeded" + MigrationStateMigrationSucceeded MigrationState = "MigrationSucceeded" + MigrationStateNone MigrationState = "None" + MigrationStateProtectionSuspended MigrationState = "ProtectionSuspended" + MigrationStateReplicating MigrationState = "Replicating" + MigrationStateResumeInProgress MigrationState = "ResumeInProgress" + MigrationStateResumeInitiated MigrationState = "ResumeInitiated" + MigrationStateSuspendingProtection MigrationState = "SuspendingProtection" +) + +func PossibleValuesForMigrationState() []string { + return []string{ + string(MigrationStateDisableMigrationFailed), + string(MigrationStateDisableMigrationInProgress), + string(MigrationStateEnableMigrationFailed), + string(MigrationStateEnableMigrationInProgress), + string(MigrationStateInitialSeedingFailed), + string(MigrationStateInitialSeedingInProgress), + string(MigrationStateMigrationCompletedWithInformation), + string(MigrationStateMigrationFailed), + string(MigrationStateMigrationInProgress), + string(MigrationStateMigrationPartiallySucceeded), + string(MigrationStateMigrationSucceeded), + string(MigrationStateNone), + string(MigrationStateProtectionSuspended), + string(MigrationStateReplicating), + string(MigrationStateResumeInProgress), + string(MigrationStateResumeInitiated), + string(MigrationStateSuspendingProtection), + } +} + +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{ + "disablemigrationfailed": MigrationStateDisableMigrationFailed, + "disablemigrationinprogress": MigrationStateDisableMigrationInProgress, + "enablemigrationfailed": MigrationStateEnableMigrationFailed, + "enablemigrationinprogress": MigrationStateEnableMigrationInProgress, + "initialseedingfailed": MigrationStateInitialSeedingFailed, + "initialseedinginprogress": MigrationStateInitialSeedingInProgress, + "migrationcompletedwithinformation": MigrationStateMigrationCompletedWithInformation, + "migrationfailed": MigrationStateMigrationFailed, + "migrationinprogress": MigrationStateMigrationInProgress, + "migrationpartiallysucceeded": MigrationStateMigrationPartiallySucceeded, + "migrationsucceeded": MigrationStateMigrationSucceeded, + "none": MigrationStateNone, + "protectionsuspended": MigrationStateProtectionSuspended, + "replicating": MigrationStateReplicating, + "resumeinprogress": MigrationStateResumeInProgress, + "resumeinitiated": MigrationStateResumeInitiated, + "suspendingprotection": MigrationStateSuspendingProtection, + } + 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 ProtectionHealth string + +const ( + ProtectionHealthCritical ProtectionHealth = "Critical" + ProtectionHealthNone ProtectionHealth = "None" + ProtectionHealthNormal ProtectionHealth = "Normal" + ProtectionHealthWarning ProtectionHealth = "Warning" +) + +func PossibleValuesForProtectionHealth() []string { + return []string{ + string(ProtectionHealthCritical), + string(ProtectionHealthNone), + string(ProtectionHealthNormal), + string(ProtectionHealthWarning), + } +} + +func (s *ProtectionHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtectionHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtectionHealth(input string) (*ProtectionHealth, error) { + vals := map[string]ProtectionHealth{ + "critical": ProtectionHealthCritical, + "none": ProtectionHealthNone, + "normal": ProtectionHealthNormal, + "warning": ProtectionHealthWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionHealth(input) + return &out, nil +} + +type ResyncState string + +const ( + ResyncStateNone ResyncState = "None" + ResyncStatePreparedForResynchronization ResyncState = "PreparedForResynchronization" + ResyncStateStartedResynchronization ResyncState = "StartedResynchronization" +) + +func PossibleValuesForResyncState() []string { + return []string{ + string(ResyncStateNone), + string(ResyncStatePreparedForResynchronization), + string(ResyncStateStartedResynchronization), + } +} + +func (s *ResyncState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResyncState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResyncState(input string) (*ResyncState, error) { + vals := map[string]ResyncState{ + "none": ResyncStateNone, + "preparedforresynchronization": ResyncStatePreparedForResynchronization, + "startedresynchronization": ResyncStateStartedResynchronization, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResyncState(input) + return &out, nil +} + +type SecurityType string + +const ( + SecurityTypeConfidentialVM SecurityType = "ConfidentialVM" + SecurityTypeNone SecurityType = "None" + SecurityTypeTrustedLaunch SecurityType = "TrustedLaunch" +) + +func PossibleValuesForSecurityType() []string { + return []string{ + string(SecurityTypeConfidentialVM), + string(SecurityTypeNone), + string(SecurityTypeTrustedLaunch), + } +} + +func (s *SecurityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityType(input string) (*SecurityType, error) { + vals := map[string]SecurityType{ + "confidentialvm": SecurityTypeConfidentialVM, + "none": SecurityTypeNone, + "trustedlaunch": SecurityTypeTrustedLaunch, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityType(input) + return &out, nil +} + +type SqlServerLicenseType string + +const ( + SqlServerLicenseTypeAHUB SqlServerLicenseType = "AHUB" + SqlServerLicenseTypeNoLicenseType SqlServerLicenseType = "NoLicenseType" + SqlServerLicenseTypeNotSpecified SqlServerLicenseType = "NotSpecified" + SqlServerLicenseTypePAYG SqlServerLicenseType = "PAYG" +) + +func PossibleValuesForSqlServerLicenseType() []string { + return []string{ + string(SqlServerLicenseTypeAHUB), + string(SqlServerLicenseTypeNoLicenseType), + string(SqlServerLicenseTypeNotSpecified), + string(SqlServerLicenseTypePAYG), + } +} + +func (s *SqlServerLicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSqlServerLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSqlServerLicenseType(input string) (*SqlServerLicenseType, error) { + vals := map[string]SqlServerLicenseType{ + "ahub": SqlServerLicenseTypeAHUB, + "nolicensetype": SqlServerLicenseTypeNoLicenseType, + "notspecified": SqlServerLicenseTypeNotSpecified, + "payg": SqlServerLicenseTypePAYG, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SqlServerLicenseType(input) + return &out, nil +} + +type TestMigrationState string + +const ( + TestMigrationStateNone TestMigrationState = "None" + TestMigrationStateTestMigrationCleanupInProgress TestMigrationState = "TestMigrationCleanupInProgress" + TestMigrationStateTestMigrationCompletedWithInformation TestMigrationState = "TestMigrationCompletedWithInformation" + TestMigrationStateTestMigrationFailed TestMigrationState = "TestMigrationFailed" + TestMigrationStateTestMigrationInProgress TestMigrationState = "TestMigrationInProgress" + TestMigrationStateTestMigrationPartiallySucceeded TestMigrationState = "TestMigrationPartiallySucceeded" + TestMigrationStateTestMigrationSucceeded TestMigrationState = "TestMigrationSucceeded" +) + +func PossibleValuesForTestMigrationState() []string { + return []string{ + string(TestMigrationStateNone), + string(TestMigrationStateTestMigrationCleanupInProgress), + string(TestMigrationStateTestMigrationCompletedWithInformation), + string(TestMigrationStateTestMigrationFailed), + string(TestMigrationStateTestMigrationInProgress), + string(TestMigrationStateTestMigrationPartiallySucceeded), + string(TestMigrationStateTestMigrationSucceeded), + } +} + +func (s *TestMigrationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTestMigrationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTestMigrationState(input string) (*TestMigrationState, error) { + vals := map[string]TestMigrationState{ + "none": TestMigrationStateNone, + "testmigrationcleanupinprogress": TestMigrationStateTestMigrationCleanupInProgress, + "testmigrationcompletedwithinformation": TestMigrationStateTestMigrationCompletedWithInformation, + "testmigrationfailed": TestMigrationStateTestMigrationFailed, + "testmigrationinprogress": TestMigrationStateTestMigrationInProgress, + "testmigrationpartiallysucceeded": TestMigrationStateTestMigrationPartiallySucceeded, + "testmigrationsucceeded": TestMigrationStateTestMigrationSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TestMigrationState(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_replicationmigrationitem.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_replicationmigrationitem.go new file mode 100644 index 00000000000..af2c070a6aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_replicationmigrationitem.go @@ -0,0 +1,157 @@ +package replicationmigrationitems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationMigrationItemId{}) +} + +var _ resourceids.ResourceId = &ReplicationMigrationItemId{} + +// ReplicationMigrationItemId is a struct representing the Resource ID for a Replication Migration Item +type ReplicationMigrationItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationMigrationItemName string +} + +// NewReplicationMigrationItemID returns a new ReplicationMigrationItemId struct +func NewReplicationMigrationItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationMigrationItemName string) ReplicationMigrationItemId { + return ReplicationMigrationItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationMigrationItemName: replicationMigrationItemName, + } +} + +// ParseReplicationMigrationItemID parses 'input' into a ReplicationMigrationItemId +func ParseReplicationMigrationItemID(input string) (*ReplicationMigrationItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationMigrationItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationMigrationItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationMigrationItemIDInsensitively parses 'input' case-insensitively into a ReplicationMigrationItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationMigrationItemIDInsensitively(input string) (*ReplicationMigrationItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationMigrationItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationMigrationItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationMigrationItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationMigrationItemName, ok = input.Parsed["replicationMigrationItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationMigrationItemName", input) + } + + return nil +} + +// ValidateReplicationMigrationItemID checks that 'input' can be parsed as a Replication Migration Item ID +func ValidateReplicationMigrationItemID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationMigrationItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Migration Item ID +func (id ReplicationMigrationItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationMigrationItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationMigrationItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Migration Item ID +func (id ReplicationMigrationItemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationMigrationItems", "replicationMigrationItems", "replicationMigrationItems"), + resourceids.UserSpecifiedSegment("replicationMigrationItemName", "replicationMigrationItemName"), + } +} + +// String returns a human-readable description of this Replication Migration Item ID +func (id ReplicationMigrationItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Migration Item Name: %q", id.ReplicationMigrationItemName), + } + return fmt.Sprintf("Replication Migration Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_replicationmigrationitem_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_replicationmigrationitem_test.go new file mode 100644 index 00000000000..3df0ca67a2d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_replicationmigrationitem_test.go @@ -0,0 +1,417 @@ +package replicationmigrationitems + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationMigrationItemId{} + +func TestNewReplicationMigrationItemID(t *testing.T) { + id := NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationMigrationItemName != "replicationMigrationItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationMigrationItemName'", id.ReplicationMigrationItemName, "replicationMigrationItemName") + } +} + +func TestFormatReplicationMigrationItemID(t *testing.T) { + actual := NewReplicationMigrationItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationMigrationItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationMigrationItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationMigrationItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationMigrationItemName: "replicationMigrationItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationMigrationItemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + } +} + +func TestParseReplicationMigrationItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationMigrationItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationMigrationItemName: "replicationMigrationItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationMigrationItems/replicationMigrationItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE", + Expected: &ReplicationMigrationItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationMigrationItemName: "rEpLiCaTiOnMiGrAtIoNiTeMnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnMiGrAtIoNiTeMs/rEpLiCaTiOnMiGrAtIoNiTeMnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationMigrationItemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationMigrationItemName != v.Expected.ReplicationMigrationItemName { + t.Fatalf("Expected %q but got %q for ReplicationMigrationItemName", v.Expected.ReplicationMigrationItemName, actual.ReplicationMigrationItemName) + } + + } +} + +func TestSegmentsForReplicationMigrationItemId(t *testing.T) { + segments := ReplicationMigrationItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationMigrationItemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..f6b59f9a420 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_replicationprotectioncontainer.go @@ -0,0 +1,148 @@ +package replicationmigrationitems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectionContainerId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..7d99ad5e9be --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationmigrationitems + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_vault.go new file mode 100644 index 00000000000..5d25616da85 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_vault.go @@ -0,0 +1,130 @@ +package replicationmigrationitems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_vault_test.go new file mode 100644 index 00000000000..b0b22c1e6a7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationmigrationitems + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_create.go new file mode 100644 index 00000000000..8bab8c5aa6d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_create.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *MigrationItem +} + +// Create ... +func (c ReplicationMigrationItemsClient) Create(ctx context.Context, id ReplicationMigrationItemId, input EnableMigrationInput) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationMigrationItemsClient) CreateThenPoll(ctx context.Context, id ReplicationMigrationItemId, input EnableMigrationInput) 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/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_delete.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_delete.go new file mode 100644 index 00000000000..f156c86538f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_delete.go @@ -0,0 +1,99 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 { + DeleteOption *string +} + +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.DeleteOption != nil { + out.Append("deleteOption", fmt.Sprintf("%v", *o.DeleteOption)) + } + return &out +} + +// Delete ... +func (c ReplicationMigrationItemsClient) Delete(ctx context.Context, id ReplicationMigrationItemId, 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 ReplicationMigrationItemsClient) DeleteThenPoll(ctx context.Context, id ReplicationMigrationItemId, 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/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_get.go new file mode 100644 index 00000000000..3baac2bfc90 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_get.go @@ -0,0 +1,53 @@ +package replicationmigrationitems + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *MigrationItem +} + +// Get ... +func (c ReplicationMigrationItemsClient) Get(ctx context.Context, id ReplicationMigrationItemId) (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 MigrationItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_list.go new file mode 100644 index 00000000000..ce56fbeda81 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_list.go @@ -0,0 +1,142 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]MigrationItem +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []MigrationItem +} + +type ListOperationOptions struct { + Filter *string + SkipToken *string + TakeToken *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)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.TakeToken != nil { + out.Append("takeToken", fmt.Sprintf("%v", *o.TakeToken)) + } + 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 ReplicationMigrationItemsClient) List(ctx context.Context, id VaultId, 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/replicationMigrationItems", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MigrationItem `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 ReplicationMigrationItemsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, MigrationItemOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationMigrationItemsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate MigrationItemOperationPredicate) (result ListCompleteResult, err error) { + items := make([]MigrationItem, 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/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_listbyreplicationprotectioncontainers.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_listbyreplicationprotectioncontainers.go new file mode 100644 index 00000000000..c2c9399a4ab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_listbyreplicationprotectioncontainers.go @@ -0,0 +1,142 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationProtectionContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MigrationItem +} + +type ListByReplicationProtectionContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []MigrationItem +} + +type ListByReplicationProtectionContainersOperationOptions struct { + Filter *string + SkipToken *string + TakeToken *string +} + +func DefaultListByReplicationProtectionContainersOperationOptions() ListByReplicationProtectionContainersOperationOptions { + return ListByReplicationProtectionContainersOperationOptions{} +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.TakeToken != nil { + out.Append("takeToken", fmt.Sprintf("%v", *o.TakeToken)) + } + return &out +} + +type ListByReplicationProtectionContainersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectionContainersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectionContainers ... +func (c ReplicationMigrationItemsClient) ListByReplicationProtectionContainers(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions) (result ListByReplicationProtectionContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByReplicationProtectionContainersCustomPager{}, + Path: fmt.Sprintf("%s/replicationMigrationItems", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MigrationItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionContainersComplete retrieves all the results into a single object +func (c ReplicationMigrationItemsClient) ListByReplicationProtectionContainersComplete(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions) (ListByReplicationProtectionContainersCompleteResult, error) { + return c.ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx, id, options, MigrationItemOperationPredicate{}) +} + +// ListByReplicationProtectionContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationMigrationItemsClient) ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions, predicate MigrationItemOperationPredicate) (result ListByReplicationProtectionContainersCompleteResult, err error) { + items := make([]MigrationItem, 0) + + resp, err := c.ListByReplicationProtectionContainers(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 = ListByReplicationProtectionContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_migrate.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_migrate.go new file mode 100644 index 00000000000..39eeccdea24 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_migrate.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *MigrationItem +} + +// Migrate ... +func (c ReplicationMigrationItemsClient) Migrate(ctx context.Context, id ReplicationMigrationItemId, input MigrateInput) (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/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 ReplicationMigrationItemsClient) MigrateThenPoll(ctx context.Context, id ReplicationMigrationItemId, input MigrateInput) 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/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_pausereplication.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_pausereplication.go new file mode 100644 index 00000000000..18b469af880 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_pausereplication.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PauseReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// PauseReplication ... +func (c ReplicationMigrationItemsClient) PauseReplication(ctx context.Context, id ReplicationMigrationItemId, input PauseReplicationInput) (result PauseReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/pauseReplication", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PauseReplicationThenPoll performs PauseReplication then polls until it's completed +func (c ReplicationMigrationItemsClient) PauseReplicationThenPoll(ctx context.Context, id ReplicationMigrationItemId, input PauseReplicationInput) error { + result, err := c.PauseReplication(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PauseReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PauseReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_resumereplication.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_resumereplication.go new file mode 100644 index 00000000000..38d610dcc9f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_resumereplication.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumeReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// ResumeReplication ... +func (c ReplicationMigrationItemsClient) ResumeReplication(ctx context.Context, id ReplicationMigrationItemId, input ResumeReplicationInput) (result ResumeReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resumeReplication", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResumeReplicationThenPoll performs ResumeReplication then polls until it's completed +func (c ReplicationMigrationItemsClient) ResumeReplicationThenPoll(ctx context.Context, id ReplicationMigrationItemId, input ResumeReplicationInput) error { + result, err := c.ResumeReplication(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ResumeReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResumeReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_resync.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_resync.go new file mode 100644 index 00000000000..dd463cfd5a0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_resync.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResyncOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// Resync ... +func (c ReplicationMigrationItemsClient) Resync(ctx context.Context, id ReplicationMigrationItemId, input ResyncInput) (result ResyncOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resync", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResyncThenPoll performs Resync then polls until it's completed +func (c ReplicationMigrationItemsClient) ResyncThenPoll(ctx context.Context, id ReplicationMigrationItemId, input ResyncInput) error { + result, err := c.Resync(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Resync: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Resync: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_testmigrate.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_testmigrate.go new file mode 100644 index 00000000000..998b9b6f304 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_testmigrate.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestMigrateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// TestMigrate ... +func (c ReplicationMigrationItemsClient) TestMigrate(ctx context.Context, id ReplicationMigrationItemId, input TestMigrateInput) (result TestMigrateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testMigrate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// TestMigrateThenPoll performs TestMigrate then polls until it's completed +func (c ReplicationMigrationItemsClient) TestMigrateThenPoll(ctx context.Context, id ReplicationMigrationItemId, input TestMigrateInput) error { + result, err := c.TestMigrate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestMigrate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestMigrate: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_testmigratecleanup.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_testmigratecleanup.go new file mode 100644 index 00000000000..0d2c2032c31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_testmigratecleanup.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestMigrateCleanupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MigrationItem +} + +// TestMigrateCleanup ... +func (c ReplicationMigrationItemsClient) TestMigrateCleanup(ctx context.Context, id ReplicationMigrationItemId, input TestMigrateCleanupInput) (result TestMigrateCleanupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testMigrateCleanup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// TestMigrateCleanupThenPoll performs TestMigrateCleanup then polls until it's completed +func (c ReplicationMigrationItemsClient) TestMigrateCleanupThenPoll(ctx context.Context, id ReplicationMigrationItemId, input TestMigrateCleanupInput) error { + result, err := c.TestMigrateCleanup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestMigrateCleanup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestMigrateCleanup: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_update.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_update.go new file mode 100644 index 00000000000..cb63d5a8133 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/method_update.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *MigrationItem +} + +// Update ... +func (c ReplicationMigrationItemsClient) Update(ctx context.Context, id ReplicationMigrationItemId, input UpdateMigrationItemInput) (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 ReplicationMigrationItemsClient) UpdateThenPoll(ctx context.Context, id ReplicationMigrationItemId, input UpdateMigrationItemInput) 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/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_appliancemonitoringdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_appliancemonitoringdetails.go new file mode 100644 index 00000000000..4fe6ced44c2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_appliancemonitoringdetails.go @@ -0,0 +1,13 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplianceMonitoringDetails struct { + CpuDetails *ApplianceResourceDetails `json:"cpuDetails,omitempty"` + DatastoreSnapshot *[]DataStoreUtilizationDetails `json:"datastoreSnapshot,omitempty"` + DisksReplicationDetails *ApplianceResourceDetails `json:"disksReplicationDetails,omitempty"` + EsxiNfcBuffer *ApplianceResourceDetails `json:"esxiNfcBuffer,omitempty"` + NetworkBandwidth *ApplianceResourceDetails `json:"networkBandwidth,omitempty"` + RamDetails *ApplianceResourceDetails `json:"ramDetails,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_applianceresourcedetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_applianceresourcedetails.go new file mode 100644 index 00000000000..d2d7263c748 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_applianceresourcedetails.go @@ -0,0 +1,11 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplianceResourceDetails struct { + Capacity *int64 `json:"capacity,omitempty"` + ProcessUtilization *float64 `json:"processUtilization,omitempty"` + Status *string `json:"status,omitempty"` + TotalUtilization *float64 `json:"totalUtilization,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_criticaljobhistorydetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_criticaljobhistorydetails.go new file mode 100644 index 00000000000..cbaf060f779 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_criticaljobhistorydetails.go @@ -0,0 +1,29 @@ +package replicationmigrationitems + +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 CriticalJobHistoryDetails struct { + JobId *string `json:"jobId,omitempty"` + JobName *string `json:"jobName,omitempty"` + JobStatus *string `json:"jobStatus,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *CriticalJobHistoryDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CriticalJobHistoryDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_currentjobdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_currentjobdetails.go new file mode 100644 index 00000000000..6461ea7fe4f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_currentjobdetails.go @@ -0,0 +1,28 @@ +package replicationmigrationitems + +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 CurrentJobDetails struct { + JobId *string `json:"jobId,omitempty"` + JobName *string `json:"jobName,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *CurrentJobDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CurrentJobDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_datastoreutilizationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_datastoreutilizationdetails.go new file mode 100644 index 00000000000..21df088d5b6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_datastoreutilizationdetails.go @@ -0,0 +1,10 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataStoreUtilizationDetails struct { + DataStoreName *string `json:"dataStoreName,omitempty"` + TotalSnapshotsCreated *int64 `json:"totalSnapshotsCreated,omitempty"` + TotalSnapshotsSupported *int64 `json:"totalSnapshotsSupported,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_enablemigrationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_enablemigrationinput.go new file mode 100644 index 00000000000..eeb46d6566e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_enablemigrationinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnableMigrationInput struct { + Properties EnableMigrationInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_enablemigrationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_enablemigrationinputproperties.go new file mode 100644 index 00000000000..a52385b5bb0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_enablemigrationinputproperties.go @@ -0,0 +1,42 @@ +package replicationmigrationitems + +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 EnableMigrationInputProperties struct { + PolicyId string `json:"policyId"` + ProviderSpecificDetails EnableMigrationProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &EnableMigrationInputProperties{} + +func (s *EnableMigrationInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + PolicyId string `json:"policyId"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.PolicyId = decoded.PolicyId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling EnableMigrationInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalEnableMigrationProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'EnableMigrationInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_enablemigrationproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_enablemigrationproviderspecificinput.go new file mode 100644 index 00000000000..9c4382643eb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_enablemigrationproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 EnableMigrationProviderSpecificInput interface { + EnableMigrationProviderSpecificInput() BaseEnableMigrationProviderSpecificInputImpl +} + +var _ EnableMigrationProviderSpecificInput = BaseEnableMigrationProviderSpecificInputImpl{} + +type BaseEnableMigrationProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseEnableMigrationProviderSpecificInputImpl) EnableMigrationProviderSpecificInput() BaseEnableMigrationProviderSpecificInputImpl { + return s +} + +var _ EnableMigrationProviderSpecificInput = RawEnableMigrationProviderSpecificInputImpl{} + +// RawEnableMigrationProviderSpecificInputImpl 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 RawEnableMigrationProviderSpecificInputImpl struct { + enableMigrationProviderSpecificInput BaseEnableMigrationProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawEnableMigrationProviderSpecificInputImpl) EnableMigrationProviderSpecificInput() BaseEnableMigrationProviderSpecificInputImpl { + return s.enableMigrationProviderSpecificInput +} + +func UnmarshalEnableMigrationProviderSpecificInputImplementation(input []byte) (EnableMigrationProviderSpecificInput, 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 EnableMigrationProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtEnableMigrationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtEnableMigrationInput: %+v", err) + } + return out, nil + } + + var parent BaseEnableMigrationProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseEnableMigrationProviderSpecificInputImpl: %+v", err) + } + + return RawEnableMigrationProviderSpecificInputImpl{ + enableMigrationProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_gatewayoperationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_gatewayoperationdetails.go new file mode 100644 index 00000000000..b0cbbc52f12 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_gatewayoperationdetails.go @@ -0,0 +1,15 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayOperationDetails struct { + DataStores *[]string `json:"dataStores,omitempty"` + HostName *string `json:"hostName,omitempty"` + ProgressPercentage *int64 `json:"progressPercentage,omitempty"` + State *string `json:"state,omitempty"` + TimeElapsed *int64 `json:"timeElapsed,omitempty"` + TimeRemaining *int64 `json:"timeRemaining,omitempty"` + UploadSpeed *int64 `json:"uploadSpeed,omitempty"` + VMwareReadThroughput *int64 `json:"vmwareReadThroughput,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_healtherror.go new file mode 100644 index 00000000000..bd011f2be40 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationmigrationitems + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_innerhealtherror.go new file mode 100644 index 00000000000..57850e37e2e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationmigrationitems + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_managedruncommandscriptinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_managedruncommandscriptinput.go new file mode 100644 index 00000000000..5ee3b09a915 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_managedruncommandscriptinput.go @@ -0,0 +1,10 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRunCommandScriptInput struct { + ScriptParameters string `json:"scriptParameters"` + ScriptURL string `json:"scriptUrl"` + StepName string `json:"stepName"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrateinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrateinput.go new file mode 100644 index 00000000000..64530958cea --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrateinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateInput struct { + Properties MigrateInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrateinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrateinputproperties.go new file mode 100644 index 00000000000..ed4cee89e09 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrateinputproperties.go @@ -0,0 +1,33 @@ +package replicationmigrationitems + +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 MigrateInputProperties struct { + ProviderSpecificDetails MigrateProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &MigrateInputProperties{} + +func (s *MigrateInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling MigrateInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalMigrateProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'MigrateInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrateproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrateproviderspecificinput.go new file mode 100644 index 00000000000..59eb089d150 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrateproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 MigrateProviderSpecificInput interface { + MigrateProviderSpecificInput() BaseMigrateProviderSpecificInputImpl +} + +var _ MigrateProviderSpecificInput = BaseMigrateProviderSpecificInputImpl{} + +type BaseMigrateProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseMigrateProviderSpecificInputImpl) MigrateProviderSpecificInput() BaseMigrateProviderSpecificInputImpl { + return s +} + +var _ MigrateProviderSpecificInput = RawMigrateProviderSpecificInputImpl{} + +// RawMigrateProviderSpecificInputImpl 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 RawMigrateProviderSpecificInputImpl struct { + migrateProviderSpecificInput BaseMigrateProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawMigrateProviderSpecificInputImpl) MigrateProviderSpecificInput() BaseMigrateProviderSpecificInputImpl { + return s.migrateProviderSpecificInput +} + +func UnmarshalMigrateProviderSpecificInputImplementation(input []byte) (MigrateProviderSpecificInput, 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 MigrateProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtMigrateInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtMigrateInput: %+v", err) + } + return out, nil + } + + var parent BaseMigrateProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseMigrateProviderSpecificInputImpl: %+v", err) + } + + return RawMigrateProviderSpecificInputImpl{ + migrateProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrationitem.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrationitem.go new file mode 100644 index 00000000000..42cd0fcb04e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrationitem.go @@ -0,0 +1,12 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationItem struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MigrationItemProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrationitemproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrationitemproperties.go new file mode 100644 index 00000000000..1061b0ce570 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrationitemproperties.go @@ -0,0 +1,123 @@ +package replicationmigrationitems + +import ( + "encoding/json" + "fmt" + "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 MigrationItemProperties struct { + AllowedOperations *[]MigrationItemOperation `json:"allowedOperations,omitempty"` + CriticalJobHistory *[]CriticalJobHistoryDetails `json:"criticalJobHistory,omitempty"` + CurrentJob *CurrentJobDetails `json:"currentJob,omitempty"` + EventCorrelationId *string `json:"eventCorrelationId,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + LastMigrationStatus *string `json:"lastMigrationStatus,omitempty"` + LastMigrationTime *string `json:"lastMigrationTime,omitempty"` + LastTestMigrationStatus *string `json:"lastTestMigrationStatus,omitempty"` + LastTestMigrationTime *string `json:"lastTestMigrationTime,omitempty"` + MachineName *string `json:"machineName,omitempty"` + MigrationState *MigrationState `json:"migrationState,omitempty"` + MigrationStateDescription *string `json:"migrationStateDescription,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProviderSpecificDetails MigrationProviderSpecificSettings `json:"providerSpecificDetails"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationStatus *string `json:"replicationStatus,omitempty"` + TestMigrateState *TestMigrationState `json:"testMigrateState,omitempty"` + TestMigrateStateDescription *string `json:"testMigrateStateDescription,omitempty"` +} + +func (o *MigrationItemProperties) GetLastMigrationTimeAsTime() (*time.Time, error) { + if o.LastMigrationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastMigrationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MigrationItemProperties) SetLastMigrationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastMigrationTime = &formatted +} + +func (o *MigrationItemProperties) GetLastTestMigrationTimeAsTime() (*time.Time, error) { + if o.LastTestMigrationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastTestMigrationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MigrationItemProperties) SetLastTestMigrationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastTestMigrationTime = &formatted +} + +var _ json.Unmarshaler = &MigrationItemProperties{} + +func (s *MigrationItemProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AllowedOperations *[]MigrationItemOperation `json:"allowedOperations,omitempty"` + CriticalJobHistory *[]CriticalJobHistoryDetails `json:"criticalJobHistory,omitempty"` + CurrentJob *CurrentJobDetails `json:"currentJob,omitempty"` + EventCorrelationId *string `json:"eventCorrelationId,omitempty"` + Health *ProtectionHealth `json:"health,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + LastMigrationStatus *string `json:"lastMigrationStatus,omitempty"` + LastMigrationTime *string `json:"lastMigrationTime,omitempty"` + LastTestMigrationStatus *string `json:"lastTestMigrationStatus,omitempty"` + LastTestMigrationTime *string `json:"lastTestMigrationTime,omitempty"` + MachineName *string `json:"machineName,omitempty"` + MigrationState *MigrationState `json:"migrationState,omitempty"` + MigrationStateDescription *string `json:"migrationStateDescription,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationStatus *string `json:"replicationStatus,omitempty"` + TestMigrateState *TestMigrationState `json:"testMigrateState,omitempty"` + TestMigrateStateDescription *string `json:"testMigrateStateDescription,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AllowedOperations = decoded.AllowedOperations + s.CriticalJobHistory = decoded.CriticalJobHistory + s.CurrentJob = decoded.CurrentJob + s.EventCorrelationId = decoded.EventCorrelationId + s.Health = decoded.Health + s.HealthErrors = decoded.HealthErrors + s.LastMigrationStatus = decoded.LastMigrationStatus + s.LastMigrationTime = decoded.LastMigrationTime + s.LastTestMigrationStatus = decoded.LastTestMigrationStatus + s.LastTestMigrationTime = decoded.LastTestMigrationTime + s.MachineName = decoded.MachineName + s.MigrationState = decoded.MigrationState + s.MigrationStateDescription = decoded.MigrationStateDescription + s.PolicyFriendlyName = decoded.PolicyFriendlyName + s.PolicyId = decoded.PolicyId + s.RecoveryServicesProviderId = decoded.RecoveryServicesProviderId + s.ReplicationStatus = decoded.ReplicationStatus + s.TestMigrateState = decoded.TestMigrateState + s.TestMigrateStateDescription = decoded.TestMigrateStateDescription + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling MigrationItemProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalMigrationProviderSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'MigrationItemProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrationproviderspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrationproviderspecificsettings.go new file mode 100644 index 00000000000..c9522606209 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_migrationproviderspecificsettings.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 MigrationProviderSpecificSettings interface { + MigrationProviderSpecificSettings() BaseMigrationProviderSpecificSettingsImpl +} + +var _ MigrationProviderSpecificSettings = BaseMigrationProviderSpecificSettingsImpl{} + +type BaseMigrationProviderSpecificSettingsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseMigrationProviderSpecificSettingsImpl) MigrationProviderSpecificSettings() BaseMigrationProviderSpecificSettingsImpl { + return s +} + +var _ MigrationProviderSpecificSettings = RawMigrationProviderSpecificSettingsImpl{} + +// RawMigrationProviderSpecificSettingsImpl 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 RawMigrationProviderSpecificSettingsImpl struct { + migrationProviderSpecificSettings BaseMigrationProviderSpecificSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawMigrationProviderSpecificSettingsImpl) MigrationProviderSpecificSettings() BaseMigrationProviderSpecificSettingsImpl { + return s.migrationProviderSpecificSettings +} + +func UnmarshalMigrationProviderSpecificSettingsImplementation(input []byte) (MigrationProviderSpecificSettings, 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 MigrationProviderSpecificSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtMigrationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtMigrationDetails: %+v", err) + } + return out, nil + } + + var parent BaseMigrationProviderSpecificSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseMigrationProviderSpecificSettingsImpl: %+v", err) + } + + return RawMigrationProviderSpecificSettingsImpl{ + migrationProviderSpecificSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_pausereplicationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_pausereplicationinput.go new file mode 100644 index 00000000000..9e6108005ed --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_pausereplicationinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PauseReplicationInput struct { + Properties PauseReplicationInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_pausereplicationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_pausereplicationinputproperties.go new file mode 100644 index 00000000000..67b7a7a192c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_pausereplicationinputproperties.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PauseReplicationInputProperties struct { + InstanceType string `json:"instanceType"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resumereplicationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resumereplicationinput.go new file mode 100644 index 00000000000..fb4429f5eac --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resumereplicationinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumeReplicationInput struct { + Properties ResumeReplicationInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resumereplicationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resumereplicationinputproperties.go new file mode 100644 index 00000000000..574d307db8b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resumereplicationinputproperties.go @@ -0,0 +1,33 @@ +package replicationmigrationitems + +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 ResumeReplicationInputProperties struct { + ProviderSpecificDetails ResumeReplicationProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ResumeReplicationInputProperties{} + +func (s *ResumeReplicationInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ResumeReplicationInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalResumeReplicationProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ResumeReplicationInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resumereplicationproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resumereplicationproviderspecificinput.go new file mode 100644 index 00000000000..9a687d6318d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resumereplicationproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 ResumeReplicationProviderSpecificInput interface { + ResumeReplicationProviderSpecificInput() BaseResumeReplicationProviderSpecificInputImpl +} + +var _ ResumeReplicationProviderSpecificInput = BaseResumeReplicationProviderSpecificInputImpl{} + +type BaseResumeReplicationProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseResumeReplicationProviderSpecificInputImpl) ResumeReplicationProviderSpecificInput() BaseResumeReplicationProviderSpecificInputImpl { + return s +} + +var _ ResumeReplicationProviderSpecificInput = RawResumeReplicationProviderSpecificInputImpl{} + +// RawResumeReplicationProviderSpecificInputImpl 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 RawResumeReplicationProviderSpecificInputImpl struct { + resumeReplicationProviderSpecificInput BaseResumeReplicationProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawResumeReplicationProviderSpecificInputImpl) ResumeReplicationProviderSpecificInput() BaseResumeReplicationProviderSpecificInputImpl { + return s.resumeReplicationProviderSpecificInput +} + +func UnmarshalResumeReplicationProviderSpecificInputImplementation(input []byte) (ResumeReplicationProviderSpecificInput, 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 ResumeReplicationProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtResumeReplicationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtResumeReplicationInput: %+v", err) + } + return out, nil + } + + var parent BaseResumeReplicationProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseResumeReplicationProviderSpecificInputImpl: %+v", err) + } + + return RawResumeReplicationProviderSpecificInputImpl{ + resumeReplicationProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resyncinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resyncinput.go new file mode 100644 index 00000000000..e680c11686e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resyncinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResyncInput struct { + Properties ResyncInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resyncinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resyncinputproperties.go new file mode 100644 index 00000000000..dc2d7fd7889 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resyncinputproperties.go @@ -0,0 +1,33 @@ +package replicationmigrationitems + +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 ResyncInputProperties struct { + ProviderSpecificDetails ResyncProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ResyncInputProperties{} + +func (s *ResyncInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ResyncInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalResyncProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ResyncInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resyncproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resyncproviderspecificinput.go new file mode 100644 index 00000000000..55138df4165 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_resyncproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 ResyncProviderSpecificInput interface { + ResyncProviderSpecificInput() BaseResyncProviderSpecificInputImpl +} + +var _ ResyncProviderSpecificInput = BaseResyncProviderSpecificInputImpl{} + +type BaseResyncProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseResyncProviderSpecificInputImpl) ResyncProviderSpecificInput() BaseResyncProviderSpecificInputImpl { + return s +} + +var _ ResyncProviderSpecificInput = RawResyncProviderSpecificInputImpl{} + +// RawResyncProviderSpecificInputImpl 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 RawResyncProviderSpecificInputImpl struct { + resyncProviderSpecificInput BaseResyncProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawResyncProviderSpecificInputImpl) ResyncProviderSpecificInput() BaseResyncProviderSpecificInputImpl { + return s.resyncProviderSpecificInput +} + +func UnmarshalResyncProviderSpecificInputImplementation(input []byte) (ResyncProviderSpecificInput, 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 ResyncProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtResyncInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtResyncInput: %+v", err) + } + return out, nil + } + + var parent BaseResyncProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseResyncProviderSpecificInputImpl: %+v", err) + } + + return RawResyncProviderSpecificInputImpl{ + resyncProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigratecleanupinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigratecleanupinput.go new file mode 100644 index 00000000000..15890ac313a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigratecleanupinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestMigrateCleanupInput struct { + Properties TestMigrateCleanupInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigratecleanupinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigratecleanupinputproperties.go new file mode 100644 index 00000000000..a7ac0568f76 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigratecleanupinputproperties.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestMigrateCleanupInputProperties struct { + Comments *string `json:"comments,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigrateinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigrateinput.go new file mode 100644 index 00000000000..cc8da4dbada --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigrateinput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestMigrateInput struct { + Properties TestMigrateInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigrateinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigrateinputproperties.go new file mode 100644 index 00000000000..dea41ea3bdd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigrateinputproperties.go @@ -0,0 +1,33 @@ +package replicationmigrationitems + +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 TestMigrateInputProperties struct { + ProviderSpecificDetails TestMigrateProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &TestMigrateInputProperties{} + +func (s *TestMigrateInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling TestMigrateInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalTestMigrateProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'TestMigrateInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigrateproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigrateproviderspecificinput.go new file mode 100644 index 00000000000..d1ce68e9003 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_testmigrateproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 TestMigrateProviderSpecificInput interface { + TestMigrateProviderSpecificInput() BaseTestMigrateProviderSpecificInputImpl +} + +var _ TestMigrateProviderSpecificInput = BaseTestMigrateProviderSpecificInputImpl{} + +type BaseTestMigrateProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseTestMigrateProviderSpecificInputImpl) TestMigrateProviderSpecificInput() BaseTestMigrateProviderSpecificInputImpl { + return s +} + +var _ TestMigrateProviderSpecificInput = RawTestMigrateProviderSpecificInputImpl{} + +// RawTestMigrateProviderSpecificInputImpl 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 RawTestMigrateProviderSpecificInputImpl struct { + testMigrateProviderSpecificInput BaseTestMigrateProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawTestMigrateProviderSpecificInputImpl) TestMigrateProviderSpecificInput() BaseTestMigrateProviderSpecificInputImpl { + return s.testMigrateProviderSpecificInput +} + +func UnmarshalTestMigrateProviderSpecificInputImplementation(input []byte) (TestMigrateProviderSpecificInput, 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 TestMigrateProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtTestMigrateInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtTestMigrateInput: %+v", err) + } + return out, nil + } + + var parent BaseTestMigrateProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseTestMigrateProviderSpecificInputImpl: %+v", err) + } + + return RawTestMigrateProviderSpecificInputImpl{ + testMigrateProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_updatemigrationiteminput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_updatemigrationiteminput.go new file mode 100644 index 00000000000..3a41aab1339 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_updatemigrationiteminput.go @@ -0,0 +1,8 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMigrationItemInput struct { + Properties *UpdateMigrationItemInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_updatemigrationiteminputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_updatemigrationiteminputproperties.go new file mode 100644 index 00000000000..8d9d71c1ca7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_updatemigrationiteminputproperties.go @@ -0,0 +1,33 @@ +package replicationmigrationitems + +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 UpdateMigrationItemInputProperties struct { + ProviderSpecificDetails UpdateMigrationItemProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &UpdateMigrationItemInputProperties{} + +func (s *UpdateMigrationItemInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateMigrationItemInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalUpdateMigrationItemProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'UpdateMigrationItemInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_updatemigrationitemproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_updatemigrationitemproviderspecificinput.go new file mode 100644 index 00000000000..a05c70810cc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_updatemigrationitemproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationmigrationitems + +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 UpdateMigrationItemProviderSpecificInput interface { + UpdateMigrationItemProviderSpecificInput() BaseUpdateMigrationItemProviderSpecificInputImpl +} + +var _ UpdateMigrationItemProviderSpecificInput = BaseUpdateMigrationItemProviderSpecificInputImpl{} + +type BaseUpdateMigrationItemProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseUpdateMigrationItemProviderSpecificInputImpl) UpdateMigrationItemProviderSpecificInput() BaseUpdateMigrationItemProviderSpecificInputImpl { + return s +} + +var _ UpdateMigrationItemProviderSpecificInput = RawUpdateMigrationItemProviderSpecificInputImpl{} + +// RawUpdateMigrationItemProviderSpecificInputImpl 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 RawUpdateMigrationItemProviderSpecificInputImpl struct { + updateMigrationItemProviderSpecificInput BaseUpdateMigrationItemProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawUpdateMigrationItemProviderSpecificInputImpl) UpdateMigrationItemProviderSpecificInput() BaseUpdateMigrationItemProviderSpecificInputImpl { + return s.updateMigrationItemProviderSpecificInput +} + +func UnmarshalUpdateMigrationItemProviderSpecificInputImplementation(input []byte) (UpdateMigrationItemProviderSpecificInput, 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 UpdateMigrationItemProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtUpdateMigrationItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtUpdateMigrationItemInput: %+v", err) + } + return out, nil + } + + var parent BaseUpdateMigrationItemProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseUpdateMigrationItemProviderSpecificInputImpl: %+v", err) + } + + return RawUpdateMigrationItemProviderSpecificInputImpl{ + updateMigrationItemProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtdiskinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtdiskinput.go new file mode 100644 index 00000000000..4eb4e883c44 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtdiskinput.go @@ -0,0 +1,17 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtDiskInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId string `json:"diskId"` + DiskSizeInGB *int64 `json:"diskSizeInGB,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + Iops *int64 `json:"iops,omitempty"` + IsOSDisk string `json:"isOSDisk"` + LogStorageAccountId string `json:"logStorageAccountId"` + LogStorageAccountSasSecretName string `json:"logStorageAccountSasSecretName"` + SectorSizeInBytes *int64 `json:"sectorSizeInBytes,omitempty"` + ThroughputInMbps *int64 `json:"throughputInMbps,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtenablemigrationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtenablemigrationinput.go new file mode 100644 index 00000000000..312133d3257 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtenablemigrationinput.go @@ -0,0 +1,76 @@ +package replicationmigrationitems + +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 _ EnableMigrationProviderSpecificInput = VMwareCbtEnableMigrationInput{} + +type VMwareCbtEnableMigrationInput struct { + ConfidentialVMKeyVaultId *string `json:"confidentialVmKeyVaultId,omitempty"` + DataMoverRunAsAccountId string `json:"dataMoverRunAsAccountId"` + DisksToInclude []VMwareCbtDiskInput `json:"disksToInclude"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + PerformAutoResync *string `json:"performAutoResync,omitempty"` + PerformSqlBulkRegistration *string `json:"performSqlBulkRegistration,omitempty"` + SeedDiskTags *map[string]string `json:"seedDiskTags,omitempty"` + SnapshotRunAsAccountId string `json:"snapshotRunAsAccountId"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetDiskTags *map[string]string `json:"targetDiskTags,omitempty"` + TargetNetworkId string `json:"targetNetworkId"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId string `json:"targetResourceGroupId"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSecurityProfile *VMwareCbtSecurityProfileProperties `json:"targetVmSecurityProfile,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` + VMwareMachineId string `json:"vmwareMachineId"` + + // Fields inherited from EnableMigrationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtEnableMigrationInput) EnableMigrationProviderSpecificInput() BaseEnableMigrationProviderSpecificInputImpl { + return BaseEnableMigrationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtEnableMigrationInput{} + +func (s VMwareCbtEnableMigrationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtEnableMigrationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtEnableMigrationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtEnableMigrationInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtEnableMigrationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtmigrateinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtmigrateinput.go new file mode 100644 index 00000000000..5c7c3385146 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtmigrateinput.go @@ -0,0 +1,52 @@ +package replicationmigrationitems + +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 _ MigrateProviderSpecificInput = VMwareCbtMigrateInput{} + +type VMwareCbtMigrateInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + PerformShutdown string `json:"performShutdown"` + PostMigrationSteps *[]ManagedRunCommandScriptInput `json:"postMigrationSteps,omitempty"` + + // Fields inherited from MigrateProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtMigrateInput) MigrateProviderSpecificInput() BaseMigrateProviderSpecificInputImpl { + return BaseMigrateProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtMigrateInput{} + +func (s VMwareCbtMigrateInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtMigrateInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtMigrateInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtMigrateInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtMigrateInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtmigrationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtmigrationdetails.go new file mode 100644 index 00000000000..5e53a8342bc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtmigrationdetails.go @@ -0,0 +1,98 @@ +package replicationmigrationitems + +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 _ MigrationProviderSpecificSettings = VMwareCbtMigrationDetails{} + +type VMwareCbtMigrationDetails struct { + ApplianceMonitoringDetails *ApplianceMonitoringDetails `json:"applianceMonitoringDetails,omitempty"` + ConfidentialVMKeyVaultId *string `json:"confidentialVmKeyVaultId,omitempty"` + DataMoverRunAsAccountId *string `json:"dataMoverRunAsAccountId,omitempty"` + DeltaSyncProgressPercentage *int64 `json:"deltaSyncProgressPercentage,omitempty"` + DeltaSyncRetryCount *int64 `json:"deltaSyncRetryCount,omitempty"` + FirmwareType *string `json:"firmwareType,omitempty"` + GatewayOperationDetails *GatewayOperationDetails `json:"gatewayOperationDetails,omitempty"` + InitialSeedingProgressPercentage *int64 `json:"initialSeedingProgressPercentage,omitempty"` + InitialSeedingRetryCount *int64 `json:"initialSeedingRetryCount,omitempty"` + IsCheckSumResyncCycle *string `json:"isCheckSumResyncCycle,omitempty"` + LastRecoveryPointId *string `json:"lastRecoveryPointId,omitempty"` + LastRecoveryPointReceived *string `json:"lastRecoveryPointReceived,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + MigrationProgressPercentage *int64 `json:"migrationProgressPercentage,omitempty"` + MigrationRecoveryPointId *string `json:"migrationRecoveryPointId,omitempty"` + OperationName *string `json:"operationName,omitempty"` + OsName *string `json:"osName,omitempty"` + OsType *string `json:"osType,omitempty"` + PerformAutoResync *string `json:"performAutoResync,omitempty"` + ProtectedDisks *[]VMwareCbtProtectedDiskDetails `json:"protectedDisks,omitempty"` + ResumeProgressPercentage *int64 `json:"resumeProgressPercentage,omitempty"` + ResumeRetryCount *int64 `json:"resumeRetryCount,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncRetryCount *int64 `json:"resyncRetryCount,omitempty"` + ResyncState *ResyncState `json:"resyncState,omitempty"` + SeedDiskTags *map[string]string `json:"seedDiskTags,omitempty"` + SnapshotRunAsAccountId *string `json:"snapshotRunAsAccountId,omitempty"` + SqlServerLicenseType *string `json:"sqlServerLicenseType,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SupportedOSVersions *[]string `json:"supportedOSVersions,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetDiskTags *map[string]string `json:"targetDiskTags,omitempty"` + TargetGeneration *string `json:"targetGeneration,omitempty"` + TargetLocation *string `json:"targetLocation,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSecurityProfile *VMwareCbtSecurityProfileProperties `json:"targetVmSecurityProfile,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + VMNics *[]VMwareCbtNicDetails `json:"vmNics,omitempty"` + VMwareMachineId *string `json:"vmwareMachineId,omitempty"` + + // Fields inherited from MigrationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtMigrationDetails) MigrationProviderSpecificSettings() BaseMigrationProviderSpecificSettingsImpl { + return BaseMigrationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtMigrationDetails{} + +func (s VMwareCbtMigrationDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtMigrationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtMigrationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtMigrationDetails: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtMigrationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtnicdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtnicdetails.go new file mode 100644 index 00000000000..068195a186f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtnicdetails.go @@ -0,0 +1,21 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtNicDetails struct { + IsPrimaryNic *string `json:"isPrimaryNic,omitempty"` + IsSelectedForMigration *string `json:"isSelectedForMigration,omitempty"` + NicId *string `json:"nicId,omitempty"` + SourceIPAddress *string `json:"sourceIPAddress,omitempty"` + SourceIPAddressType *EthernetAddressType `json:"sourceIPAddressType,omitempty"` + SourceNetworkId *string `json:"sourceNetworkId,omitempty"` + TargetIPAddress *string `json:"targetIPAddress,omitempty"` + TargetIPAddressType *EthernetAddressType `json:"targetIPAddressType,omitempty"` + TargetNicName *string `json:"targetNicName,omitempty"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TestIPAddress *string `json:"testIPAddress,omitempty"` + TestIPAddressType *EthernetAddressType `json:"testIPAddressType,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtnicinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtnicinput.go new file mode 100644 index 00000000000..43ec27bd70b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtnicinput.go @@ -0,0 +1,15 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtNicInput struct { + IsPrimaryNic string `json:"isPrimaryNic"` + IsSelectedForMigration *string `json:"isSelectedForMigration,omitempty"` + NicId string `json:"nicId"` + TargetNicName *string `json:"targetNicName,omitempty"` + TargetStaticIPAddress *string `json:"targetStaticIPAddress,omitempty"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TestStaticIPAddress *string `json:"testStaticIPAddress,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtprotecteddiskdetails.go new file mode 100644 index 00000000000..02258f6e199 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtprotecteddiskdetails.go @@ -0,0 +1,26 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtProtectedDiskDetails struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskPath *string `json:"diskPath,omitempty"` + DiskSizeInGB *int64 `json:"diskSizeInGB,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + GatewayOperationDetails *GatewayOperationDetails `json:"gatewayOperationDetails,omitempty"` + Iops *int64 `json:"iops,omitempty"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + LogStorageAccountSasSecretName *string `json:"logStorageAccountSasSecretName,omitempty"` + SectorSizeInBytes *int64 `json:"sectorSizeInBytes,omitempty"` + SeedBlobUri *string `json:"seedBlobUri,omitempty"` + SeedManagedDiskId *string `json:"seedManagedDiskId,omitempty"` + TargetBlobUri *string `json:"targetBlobUri,omitempty"` + TargetDiskName *string `json:"targetDiskName,omitempty"` + TargetManagedDiskId *string `json:"targetManagedDiskId,omitempty"` + ThroughputInMbps *int64 `json:"throughputInMbps,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtresumereplicationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtresumereplicationinput.go new file mode 100644 index 00000000000..1c6cf9977e7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtresumereplicationinput.go @@ -0,0 +1,50 @@ +package replicationmigrationitems + +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 _ ResumeReplicationProviderSpecificInput = VMwareCbtResumeReplicationInput{} + +type VMwareCbtResumeReplicationInput struct { + DeleteMigrationResources *string `json:"deleteMigrationResources,omitempty"` + + // Fields inherited from ResumeReplicationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtResumeReplicationInput) ResumeReplicationProviderSpecificInput() BaseResumeReplicationProviderSpecificInputImpl { + return BaseResumeReplicationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtResumeReplicationInput{} + +func (s VMwareCbtResumeReplicationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtResumeReplicationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtResumeReplicationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtResumeReplicationInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtResumeReplicationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtresyncinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtresyncinput.go new file mode 100644 index 00000000000..f5b5c166ad1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtresyncinput.go @@ -0,0 +1,50 @@ +package replicationmigrationitems + +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 _ ResyncProviderSpecificInput = VMwareCbtResyncInput{} + +type VMwareCbtResyncInput struct { + SkipCbtReset string `json:"skipCbtReset"` + + // Fields inherited from ResyncProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtResyncInput) ResyncProviderSpecificInput() BaseResyncProviderSpecificInputImpl { + return BaseResyncProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtResyncInput{} + +func (s VMwareCbtResyncInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtResyncInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtResyncInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtResyncInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtResyncInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtsecurityprofileproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtsecurityprofileproperties.go new file mode 100644 index 00000000000..8bca1ef02df --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtsecurityprofileproperties.go @@ -0,0 +1,12 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtSecurityProfileProperties struct { + IsTargetVMConfidentialEncryptionEnabled *string `json:"isTargetVmConfidentialEncryptionEnabled,omitempty"` + IsTargetVMIntegrityMonitoringEnabled *string `json:"isTargetVmIntegrityMonitoringEnabled,omitempty"` + IsTargetVMSecureBootEnabled *string `json:"isTargetVmSecureBootEnabled,omitempty"` + IsTargetVMTpmEnabled *string `json:"isTargetVmTpmEnabled,omitempty"` + TargetVMSecurityType *SecurityType `json:"targetVmSecurityType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbttestmigrateinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbttestmigrateinput.go new file mode 100644 index 00000000000..0ec2adcc035 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbttestmigrateinput.go @@ -0,0 +1,54 @@ +package replicationmigrationitems + +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 _ TestMigrateProviderSpecificInput = VMwareCbtTestMigrateInput{} + +type VMwareCbtTestMigrateInput struct { + NetworkId string `json:"networkId"` + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + PostMigrationSteps *[]ManagedRunCommandScriptInput `json:"postMigrationSteps,omitempty"` + RecoveryPointId string `json:"recoveryPointId"` + VMNics *[]VMwareCbtNicInput `json:"vmNics,omitempty"` + + // Fields inherited from TestMigrateProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtTestMigrateInput) TestMigrateProviderSpecificInput() BaseTestMigrateProviderSpecificInputImpl { + return BaseTestMigrateProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtTestMigrateInput{} + +func (s VMwareCbtTestMigrateInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtTestMigrateInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtTestMigrateInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtTestMigrateInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtTestMigrateInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtupdatediskinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtupdatediskinput.go new file mode 100644 index 00000000000..909d64d53d0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtupdatediskinput.go @@ -0,0 +1,13 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMwareCbtUpdateDiskInput struct { + DiskId string `json:"diskId"` + DiskSizeInGB *int64 `json:"diskSizeInGB,omitempty"` + Iops *int64 `json:"iops,omitempty"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + TargetDiskName *string `json:"targetDiskName,omitempty"` + ThroughputInMbps *int64 `json:"throughputInMbps,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtupdatemigrationiteminput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtupdatemigrationiteminput.go new file mode 100644 index 00000000000..f018f6cf6f2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/model_vmwarecbtupdatemigrationiteminput.go @@ -0,0 +1,68 @@ +package replicationmigrationitems + +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 _ UpdateMigrationItemProviderSpecificInput = VMwareCbtUpdateMigrationItemInput{} + +type VMwareCbtUpdateMigrationItemInput struct { + LicenseType *LicenseType `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + PerformAutoResync *string `json:"performAutoResync,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetDiskTags *map[string]string `json:"targetDiskTags,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` + VMDisks *[]VMwareCbtUpdateDiskInput `json:"vmDisks,omitempty"` + VMNics *[]VMwareCbtNicInput `json:"vmNics,omitempty"` + + // Fields inherited from UpdateMigrationItemProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtUpdateMigrationItemInput) UpdateMigrationItemProviderSpecificInput() BaseUpdateMigrationItemProviderSpecificInputImpl { + return BaseUpdateMigrationItemProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtUpdateMigrationItemInput{} + +func (s VMwareCbtUpdateMigrationItemInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtUpdateMigrationItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtUpdateMigrationItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtUpdateMigrationItemInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtUpdateMigrationItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/predicates.go new file mode 100644 index 00000000000..38625eaca48 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/predicates.go @@ -0,0 +1,32 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrationItemOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p MigrationItemOperationPredicate) Matches(input MigrationItem) 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/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/version.go new file mode 100644 index 00000000000..7787ac53a99 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationmigrationitems/version.go @@ -0,0 +1,10 @@ +package replicationmigrationitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationmigrationitems/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/README.md new file mode 100644 index 00000000000..2a90544e349 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings` Documentation + +The `replicationnetworkmappings` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings" +``` + + +### Client Initialization + +```go +client := replicationnetworkmappings.NewReplicationNetworkMappingsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationNetworkMappingsClient.Create` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName", "replicationNetworkMappingName") + +payload := replicationnetworkmappings.CreateNetworkMappingInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationNetworkMappingsClient.Delete` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName", "replicationNetworkMappingName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationNetworkMappingsClient.Get` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName", "replicationNetworkMappingName") + +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: `ReplicationNetworkMappingsClient.List` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// 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: `ReplicationNetworkMappingsClient.ListByReplicationNetworks` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName") + +// alternatively `client.ListByReplicationNetworks(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationNetworksComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationNetworkMappingsClient.Update` + +```go +ctx := context.TODO() +id := replicationnetworkmappings.NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName", "replicationNetworkMappingName") + +payload := replicationnetworkmappings.UpdateNetworkMappingInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/client.go new file mode 100644 index 00000000000..abd39f3fa7e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/client.go @@ -0,0 +1,26 @@ +package replicationnetworkmappings + +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 ReplicationNetworkMappingsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationNetworkMappingsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationNetworkMappingsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationnetworkmappings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationNetworkMappingsClient: %+v", err) + } + + return &ReplicationNetworkMappingsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_replicationnetwork.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_replicationnetwork.go new file mode 100644 index 00000000000..bc0a19b4b6e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_replicationnetwork.go @@ -0,0 +1,148 @@ +package replicationnetworkmappings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationNetworkId{}) +} + +var _ resourceids.ResourceId = &ReplicationNetworkId{} + +// ReplicationNetworkId is a struct representing the Resource ID for a Replication Network +type ReplicationNetworkId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationNetworkName string +} + +// NewReplicationNetworkID returns a new ReplicationNetworkId struct +func NewReplicationNetworkID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationNetworkName string) ReplicationNetworkId { + return ReplicationNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationNetworkName: replicationNetworkName, + } +} + +// ParseReplicationNetworkID parses 'input' into a ReplicationNetworkId +func ParseReplicationNetworkID(input string) (*ReplicationNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationNetworkIDInsensitively parses 'input' case-insensitively into a ReplicationNetworkId +// note: this method should only be used for API response data and not user input +func ParseReplicationNetworkIDInsensitively(input string) (*ReplicationNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationNetworkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationNetworkName, ok = input.Parsed["replicationNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationNetworkName", input) + } + + return nil +} + +// ValidateReplicationNetworkID checks that 'input' can be parsed as a Replication Network ID +func ValidateReplicationNetworkID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Network ID +func (id ReplicationNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Network ID +func (id ReplicationNetworkId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationNetworks", "replicationNetworks", "replicationNetworks"), + resourceids.UserSpecifiedSegment("replicationNetworkName", "replicationNetworkName"), + } +} + +// String returns a human-readable description of this Replication Network ID +func (id ReplicationNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Network Name: %q", id.ReplicationNetworkName), + } + return fmt.Sprintf("Replication Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_replicationnetwork_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_replicationnetwork_test.go new file mode 100644 index 00000000000..82963269f22 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_replicationnetwork_test.go @@ -0,0 +1,372 @@ +package replicationnetworkmappings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationNetworkId{} + +func TestNewReplicationNetworkID(t *testing.T) { + id := NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationNetworkName != "replicationNetworkName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationNetworkName'", id.ReplicationNetworkName, "replicationNetworkName") + } +} + +func TestFormatReplicationNetworkID(t *testing.T) { + actual := NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationNetworkName: "replicationNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + } +} + +func TestParseReplicationNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationNetworkName: "replicationNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationNetworkName: "rEpLiCaTiOnNeTwOrKnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + } +} + +func TestSegmentsForReplicationNetworkId(t *testing.T) { + segments := ReplicationNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationNetworkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_replicationnetworkmapping.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_replicationnetworkmapping.go new file mode 100644 index 00000000000..f35ea2e5232 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_replicationnetworkmapping.go @@ -0,0 +1,157 @@ +package replicationnetworkmappings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationNetworkMappingId{}) +} + +var _ resourceids.ResourceId = &ReplicationNetworkMappingId{} + +// ReplicationNetworkMappingId is a struct representing the Resource ID for a Replication Network Mapping +type ReplicationNetworkMappingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationNetworkName string + ReplicationNetworkMappingName string +} + +// NewReplicationNetworkMappingID returns a new ReplicationNetworkMappingId struct +func NewReplicationNetworkMappingID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationNetworkName string, replicationNetworkMappingName string) ReplicationNetworkMappingId { + return ReplicationNetworkMappingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationNetworkName: replicationNetworkName, + ReplicationNetworkMappingName: replicationNetworkMappingName, + } +} + +// ParseReplicationNetworkMappingID parses 'input' into a ReplicationNetworkMappingId +func ParseReplicationNetworkMappingID(input string) (*ReplicationNetworkMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkMappingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkMappingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationNetworkMappingIDInsensitively parses 'input' case-insensitively into a ReplicationNetworkMappingId +// note: this method should only be used for API response data and not user input +func ParseReplicationNetworkMappingIDInsensitively(input string) (*ReplicationNetworkMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkMappingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkMappingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationNetworkMappingId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationNetworkName, ok = input.Parsed["replicationNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationNetworkName", input) + } + + if id.ReplicationNetworkMappingName, ok = input.Parsed["replicationNetworkMappingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationNetworkMappingName", input) + } + + return nil +} + +// ValidateReplicationNetworkMappingID checks that 'input' can be parsed as a Replication Network Mapping ID +func ValidateReplicationNetworkMappingID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationNetworkMappingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Network Mapping ID +func (id ReplicationNetworkMappingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationNetworks/%s/replicationNetworkMappings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationNetworkName, id.ReplicationNetworkMappingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Network Mapping ID +func (id ReplicationNetworkMappingId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationNetworks", "replicationNetworks", "replicationNetworks"), + resourceids.UserSpecifiedSegment("replicationNetworkName", "replicationNetworkName"), + resourceids.StaticSegment("staticReplicationNetworkMappings", "replicationNetworkMappings", "replicationNetworkMappings"), + resourceids.UserSpecifiedSegment("replicationNetworkMappingName", "replicationNetworkMappingName"), + } +} + +// String returns a human-readable description of this Replication Network Mapping ID +func (id ReplicationNetworkMappingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Network Name: %q", id.ReplicationNetworkName), + fmt.Sprintf("Replication Network Mapping Name: %q", id.ReplicationNetworkMappingName), + } + return fmt.Sprintf("Replication Network Mapping (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_replicationnetworkmapping_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_replicationnetworkmapping_test.go new file mode 100644 index 00000000000..1d386c1e039 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_replicationnetworkmapping_test.go @@ -0,0 +1,417 @@ +package replicationnetworkmappings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationNetworkMappingId{} + +func TestNewReplicationNetworkMappingID(t *testing.T) { + id := NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName", "replicationNetworkMappingName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationNetworkName != "replicationNetworkName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationNetworkName'", id.ReplicationNetworkName, "replicationNetworkName") + } + + if id.ReplicationNetworkMappingName != "replicationNetworkMappingName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationNetworkMappingName'", id.ReplicationNetworkMappingName, "replicationNetworkMappingName") + } +} + +func TestFormatReplicationNetworkMappingID(t *testing.T) { + actual := NewReplicationNetworkMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName", "replicationNetworkMappingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/replicationNetworkMappings/replicationNetworkMappingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationNetworkMappingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkMappingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/replicationNetworkMappings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/replicationNetworkMappings/replicationNetworkMappingName", + Expected: &ReplicationNetworkMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationNetworkName: "replicationNetworkName", + ReplicationNetworkMappingName: "replicationNetworkMappingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/replicationNetworkMappings/replicationNetworkMappingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkMappingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + if actual.ReplicationNetworkMappingName != v.Expected.ReplicationNetworkMappingName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkMappingName", v.Expected.ReplicationNetworkMappingName, actual.ReplicationNetworkMappingName) + } + + } +} + +func TestParseReplicationNetworkMappingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkMappingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/replicationNetworkMappings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE/rEpLiCaTiOnNeTwOrKmApPiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/replicationNetworkMappings/replicationNetworkMappingName", + Expected: &ReplicationNetworkMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationNetworkName: "replicationNetworkName", + ReplicationNetworkMappingName: "replicationNetworkMappingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/replicationNetworkMappings/replicationNetworkMappingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE/rEpLiCaTiOnNeTwOrKmApPiNgS/rEpLiCaTiOnNeTwOrKmApPiNgNaMe", + Expected: &ReplicationNetworkMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationNetworkName: "rEpLiCaTiOnNeTwOrKnAmE", + ReplicationNetworkMappingName: "rEpLiCaTiOnNeTwOrKmApPiNgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE/rEpLiCaTiOnNeTwOrKmApPiNgS/rEpLiCaTiOnNeTwOrKmApPiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkMappingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + if actual.ReplicationNetworkMappingName != v.Expected.ReplicationNetworkMappingName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkMappingName", v.Expected.ReplicationNetworkMappingName, actual.ReplicationNetworkMappingName) + } + + } +} + +func TestSegmentsForReplicationNetworkMappingId(t *testing.T) { + segments := ReplicationNetworkMappingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationNetworkMappingId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_vault.go new file mode 100644 index 00000000000..5cecc8e3e7f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_vault.go @@ -0,0 +1,130 @@ +package replicationnetworkmappings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_vault_test.go new file mode 100644 index 00000000000..0403f3ac48e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationnetworkmappings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_create.go new file mode 100644 index 00000000000..a4d2be62b74 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_create.go @@ -0,0 +1,75 @@ +package replicationnetworkmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *NetworkMapping +} + +// Create ... +func (c ReplicationNetworkMappingsClient) Create(ctx context.Context, id ReplicationNetworkMappingId, input CreateNetworkMappingInput) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationNetworkMappingsClient) CreateThenPoll(ctx context.Context, id ReplicationNetworkMappingId, input CreateNetworkMappingInput) 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/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_delete.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_delete.go new file mode 100644 index 00000000000..3adf449be4b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_delete.go @@ -0,0 +1,70 @@ +package replicationnetworkmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 ReplicationNetworkMappingsClient) Delete(ctx context.Context, id ReplicationNetworkMappingId) (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 ReplicationNetworkMappingsClient) DeleteThenPoll(ctx context.Context, id ReplicationNetworkMappingId) 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/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_get.go new file mode 100644 index 00000000000..525a5254824 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_get.go @@ -0,0 +1,53 @@ +package replicationnetworkmappings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *NetworkMapping +} + +// Get ... +func (c ReplicationNetworkMappingsClient) Get(ctx context.Context, id ReplicationNetworkMappingId) (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 NetworkMapping + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_list.go new file mode 100644 index 00000000000..c8dfd95c67d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_list.go @@ -0,0 +1,105 @@ +package replicationnetworkmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]NetworkMapping +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkMapping +} + +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 ReplicationNetworkMappingsClient) List(ctx context.Context, id VaultId) (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/replicationNetworkMappings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkMapping `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 ReplicationNetworkMappingsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, NetworkMappingOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationNetworkMappingsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate NetworkMappingOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NetworkMapping, 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/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_listbyreplicationnetworks.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_listbyreplicationnetworks.go new file mode 100644 index 00000000000..51e7d93a04b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_listbyreplicationnetworks.go @@ -0,0 +1,105 @@ +package replicationnetworkmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationNetworksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkMapping +} + +type ListByReplicationNetworksCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkMapping +} + +type ListByReplicationNetworksCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationNetworksCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationNetworks ... +func (c ReplicationNetworkMappingsClient) ListByReplicationNetworks(ctx context.Context, id ReplicationNetworkId) (result ListByReplicationNetworksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationNetworksCustomPager{}, + Path: fmt.Sprintf("%s/replicationNetworkMappings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationNetworksComplete retrieves all the results into a single object +func (c ReplicationNetworkMappingsClient) ListByReplicationNetworksComplete(ctx context.Context, id ReplicationNetworkId) (ListByReplicationNetworksCompleteResult, error) { + return c.ListByReplicationNetworksCompleteMatchingPredicate(ctx, id, NetworkMappingOperationPredicate{}) +} + +// ListByReplicationNetworksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationNetworkMappingsClient) ListByReplicationNetworksCompleteMatchingPredicate(ctx context.Context, id ReplicationNetworkId, predicate NetworkMappingOperationPredicate) (result ListByReplicationNetworksCompleteResult, err error) { + items := make([]NetworkMapping, 0) + + resp, err := c.ListByReplicationNetworks(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 = ListByReplicationNetworksCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_update.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_update.go new file mode 100644 index 00000000000..bbd5fc8d76f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/method_update.go @@ -0,0 +1,75 @@ +package replicationnetworkmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *NetworkMapping +} + +// Update ... +func (c ReplicationNetworkMappingsClient) Update(ctx context.Context, id ReplicationNetworkMappingId, input UpdateNetworkMappingInput) (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 ReplicationNetworkMappingsClient) UpdateThenPoll(ctx context.Context, id ReplicationNetworkMappingId, input UpdateNetworkMappingInput) 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/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_azuretoazurecreatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_azuretoazurecreatenetworkmappinginput.go new file mode 100644 index 00000000000..bf9c068eb17 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_azuretoazurecreatenetworkmappinginput.go @@ -0,0 +1,50 @@ +package replicationnetworkmappings + +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 _ FabricSpecificCreateNetworkMappingInput = AzureToAzureCreateNetworkMappingInput{} + +type AzureToAzureCreateNetworkMappingInput struct { + PrimaryNetworkId string `json:"primaryNetworkId"` + + // Fields inherited from FabricSpecificCreateNetworkMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s AzureToAzureCreateNetworkMappingInput) FabricSpecificCreateNetworkMappingInput() BaseFabricSpecificCreateNetworkMappingInputImpl { + return BaseFabricSpecificCreateNetworkMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = AzureToAzureCreateNetworkMappingInput{} + +func (s AzureToAzureCreateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper AzureToAzureCreateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureToAzureCreateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureToAzureCreateNetworkMappingInput: %+v", err) + } + + decoded["instanceType"] = "AzureToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureToAzureCreateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_azuretoazurenetworkmappingsettings.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_azuretoazurenetworkmappingsettings.go new file mode 100644 index 00000000000..3c54371de7d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_azuretoazurenetworkmappingsettings.go @@ -0,0 +1,51 @@ +package replicationnetworkmappings + +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 _ NetworkMappingFabricSpecificSettings = AzureToAzureNetworkMappingSettings{} + +type AzureToAzureNetworkMappingSettings struct { + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` + + // Fields inherited from NetworkMappingFabricSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s AzureToAzureNetworkMappingSettings) NetworkMappingFabricSpecificSettings() BaseNetworkMappingFabricSpecificSettingsImpl { + return BaseNetworkMappingFabricSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = AzureToAzureNetworkMappingSettings{} + +func (s AzureToAzureNetworkMappingSettings) MarshalJSON() ([]byte, error) { + type wrapper AzureToAzureNetworkMappingSettings + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureToAzureNetworkMappingSettings: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureToAzureNetworkMappingSettings: %+v", err) + } + + decoded["instanceType"] = "AzureToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureToAzureNetworkMappingSettings: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_azuretoazureupdatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_azuretoazureupdatenetworkmappinginput.go new file mode 100644 index 00000000000..712bd15b869 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_azuretoazureupdatenetworkmappinginput.go @@ -0,0 +1,50 @@ +package replicationnetworkmappings + +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 _ FabricSpecificUpdateNetworkMappingInput = AzureToAzureUpdateNetworkMappingInput{} + +type AzureToAzureUpdateNetworkMappingInput struct { + PrimaryNetworkId *string `json:"primaryNetworkId,omitempty"` + + // Fields inherited from FabricSpecificUpdateNetworkMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s AzureToAzureUpdateNetworkMappingInput) FabricSpecificUpdateNetworkMappingInput() BaseFabricSpecificUpdateNetworkMappingInputImpl { + return BaseFabricSpecificUpdateNetworkMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = AzureToAzureUpdateNetworkMappingInput{} + +func (s AzureToAzureUpdateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper AzureToAzureUpdateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureToAzureUpdateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureToAzureUpdateNetworkMappingInput: %+v", err) + } + + decoded["instanceType"] = "AzureToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureToAzureUpdateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_createnetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_createnetworkmappinginput.go new file mode 100644 index 00000000000..1465b2453c9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_createnetworkmappinginput.go @@ -0,0 +1,8 @@ +package replicationnetworkmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateNetworkMappingInput struct { + Properties CreateNetworkMappingInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_createnetworkmappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_createnetworkmappinginputproperties.go new file mode 100644 index 00000000000..792db7cc081 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_createnetworkmappinginputproperties.go @@ -0,0 +1,45 @@ +package replicationnetworkmappings + +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 CreateNetworkMappingInputProperties struct { + FabricSpecificDetails FabricSpecificCreateNetworkMappingInput `json:"fabricSpecificDetails"` + RecoveryFabricName *string `json:"recoveryFabricName,omitempty"` + RecoveryNetworkId string `json:"recoveryNetworkId"` +} + +var _ json.Unmarshaler = &CreateNetworkMappingInputProperties{} + +func (s *CreateNetworkMappingInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + RecoveryFabricName *string `json:"recoveryFabricName,omitempty"` + RecoveryNetworkId string `json:"recoveryNetworkId"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.RecoveryFabricName = decoded.RecoveryFabricName + s.RecoveryNetworkId = decoded.RecoveryNetworkId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateNetworkMappingInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["fabricSpecificDetails"]; ok { + impl, err := UnmarshalFabricSpecificCreateNetworkMappingInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'FabricSpecificDetails' for 'CreateNetworkMappingInputProperties': %+v", err) + } + s.FabricSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_fabricspecificcreatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_fabricspecificcreatenetworkmappinginput.go new file mode 100644 index 00000000000..ead65c29e3f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_fabricspecificcreatenetworkmappinginput.go @@ -0,0 +1,91 @@ +package replicationnetworkmappings + +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 FabricSpecificCreateNetworkMappingInput interface { + FabricSpecificCreateNetworkMappingInput() BaseFabricSpecificCreateNetworkMappingInputImpl +} + +var _ FabricSpecificCreateNetworkMappingInput = BaseFabricSpecificCreateNetworkMappingInputImpl{} + +type BaseFabricSpecificCreateNetworkMappingInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseFabricSpecificCreateNetworkMappingInputImpl) FabricSpecificCreateNetworkMappingInput() BaseFabricSpecificCreateNetworkMappingInputImpl { + return s +} + +var _ FabricSpecificCreateNetworkMappingInput = RawFabricSpecificCreateNetworkMappingInputImpl{} + +// RawFabricSpecificCreateNetworkMappingInputImpl 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 RawFabricSpecificCreateNetworkMappingInputImpl struct { + fabricSpecificCreateNetworkMappingInput BaseFabricSpecificCreateNetworkMappingInputImpl + Type string + Values map[string]interface{} +} + +func (s RawFabricSpecificCreateNetworkMappingInputImpl) FabricSpecificCreateNetworkMappingInput() BaseFabricSpecificCreateNetworkMappingInputImpl { + return s.fabricSpecificCreateNetworkMappingInput +} + +func UnmarshalFabricSpecificCreateNetworkMappingInputImplementation(input []byte) (FabricSpecificCreateNetworkMappingInput, 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 FabricSpecificCreateNetworkMappingInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureToAzure") { + var out AzureToAzureCreateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureToAzureCreateNetworkMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToAzure") { + var out VMmToAzureCreateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToAzureCreateNetworkMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToVmm") { + var out VMmToVMmCreateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToVMmCreateNetworkMappingInput: %+v", err) + } + return out, nil + } + + var parent BaseFabricSpecificCreateNetworkMappingInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFabricSpecificCreateNetworkMappingInputImpl: %+v", err) + } + + return RawFabricSpecificCreateNetworkMappingInputImpl{ + fabricSpecificCreateNetworkMappingInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_fabricspecificupdatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_fabricspecificupdatenetworkmappinginput.go new file mode 100644 index 00000000000..1619f21a4f5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_fabricspecificupdatenetworkmappinginput.go @@ -0,0 +1,91 @@ +package replicationnetworkmappings + +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 FabricSpecificUpdateNetworkMappingInput interface { + FabricSpecificUpdateNetworkMappingInput() BaseFabricSpecificUpdateNetworkMappingInputImpl +} + +var _ FabricSpecificUpdateNetworkMappingInput = BaseFabricSpecificUpdateNetworkMappingInputImpl{} + +type BaseFabricSpecificUpdateNetworkMappingInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseFabricSpecificUpdateNetworkMappingInputImpl) FabricSpecificUpdateNetworkMappingInput() BaseFabricSpecificUpdateNetworkMappingInputImpl { + return s +} + +var _ FabricSpecificUpdateNetworkMappingInput = RawFabricSpecificUpdateNetworkMappingInputImpl{} + +// RawFabricSpecificUpdateNetworkMappingInputImpl 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 RawFabricSpecificUpdateNetworkMappingInputImpl struct { + fabricSpecificUpdateNetworkMappingInput BaseFabricSpecificUpdateNetworkMappingInputImpl + Type string + Values map[string]interface{} +} + +func (s RawFabricSpecificUpdateNetworkMappingInputImpl) FabricSpecificUpdateNetworkMappingInput() BaseFabricSpecificUpdateNetworkMappingInputImpl { + return s.fabricSpecificUpdateNetworkMappingInput +} + +func UnmarshalFabricSpecificUpdateNetworkMappingInputImplementation(input []byte) (FabricSpecificUpdateNetworkMappingInput, 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 FabricSpecificUpdateNetworkMappingInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureToAzure") { + var out AzureToAzureUpdateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureToAzureUpdateNetworkMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToAzure") { + var out VMmToAzureUpdateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToAzureUpdateNetworkMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToVmm") { + var out VMmToVMmUpdateNetworkMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToVMmUpdateNetworkMappingInput: %+v", err) + } + return out, nil + } + + var parent BaseFabricSpecificUpdateNetworkMappingInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFabricSpecificUpdateNetworkMappingInputImpl: %+v", err) + } + + return RawFabricSpecificUpdateNetworkMappingInputImpl{ + fabricSpecificUpdateNetworkMappingInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_networkmapping.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_networkmapping.go new file mode 100644 index 00000000000..920122dece0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_networkmapping.go @@ -0,0 +1,12 @@ +package replicationnetworkmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkMapping struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkMappingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_networkmappingfabricspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_networkmappingfabricspecificsettings.go new file mode 100644 index 00000000000..cc0f8272959 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_networkmappingfabricspecificsettings.go @@ -0,0 +1,91 @@ +package replicationnetworkmappings + +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 NetworkMappingFabricSpecificSettings interface { + NetworkMappingFabricSpecificSettings() BaseNetworkMappingFabricSpecificSettingsImpl +} + +var _ NetworkMappingFabricSpecificSettings = BaseNetworkMappingFabricSpecificSettingsImpl{} + +type BaseNetworkMappingFabricSpecificSettingsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseNetworkMappingFabricSpecificSettingsImpl) NetworkMappingFabricSpecificSettings() BaseNetworkMappingFabricSpecificSettingsImpl { + return s +} + +var _ NetworkMappingFabricSpecificSettings = RawNetworkMappingFabricSpecificSettingsImpl{} + +// RawNetworkMappingFabricSpecificSettingsImpl 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 RawNetworkMappingFabricSpecificSettingsImpl struct { + networkMappingFabricSpecificSettings BaseNetworkMappingFabricSpecificSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawNetworkMappingFabricSpecificSettingsImpl) NetworkMappingFabricSpecificSettings() BaseNetworkMappingFabricSpecificSettingsImpl { + return s.networkMappingFabricSpecificSettings +} + +func UnmarshalNetworkMappingFabricSpecificSettingsImplementation(input []byte) (NetworkMappingFabricSpecificSettings, 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 NetworkMappingFabricSpecificSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureToAzure") { + var out AzureToAzureNetworkMappingSettings + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureToAzureNetworkMappingSettings: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToAzure") { + var out VMmToAzureNetworkMappingSettings + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToAzureNetworkMappingSettings: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VmmToVmm") { + var out VMmToVMmNetworkMappingSettings + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMmToVMmNetworkMappingSettings: %+v", err) + } + return out, nil + } + + var parent BaseNetworkMappingFabricSpecificSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseNetworkMappingFabricSpecificSettingsImpl: %+v", err) + } + + return RawNetworkMappingFabricSpecificSettingsImpl{ + networkMappingFabricSpecificSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_networkmappingproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_networkmappingproperties.go new file mode 100644 index 00000000000..2dbab290e69 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_networkmappingproperties.go @@ -0,0 +1,63 @@ +package replicationnetworkmappings + +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 NetworkMappingProperties struct { + FabricSpecificSettings NetworkMappingFabricSpecificSettings `json:"fabricSpecificSettings"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryNetworkFriendlyName *string `json:"primaryNetworkFriendlyName,omitempty"` + PrimaryNetworkId *string `json:"primaryNetworkId,omitempty"` + RecoveryFabricArmId *string `json:"recoveryFabricArmId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryNetworkFriendlyName *string `json:"recoveryNetworkFriendlyName,omitempty"` + RecoveryNetworkId *string `json:"recoveryNetworkId,omitempty"` + State *string `json:"state,omitempty"` +} + +var _ json.Unmarshaler = &NetworkMappingProperties{} + +func (s *NetworkMappingProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryNetworkFriendlyName *string `json:"primaryNetworkFriendlyName,omitempty"` + PrimaryNetworkId *string `json:"primaryNetworkId,omitempty"` + RecoveryFabricArmId *string `json:"recoveryFabricArmId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryNetworkFriendlyName *string `json:"recoveryNetworkFriendlyName,omitempty"` + RecoveryNetworkId *string `json:"recoveryNetworkId,omitempty"` + State *string `json:"state,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.PrimaryFabricFriendlyName = decoded.PrimaryFabricFriendlyName + s.PrimaryNetworkFriendlyName = decoded.PrimaryNetworkFriendlyName + s.PrimaryNetworkId = decoded.PrimaryNetworkId + s.RecoveryFabricArmId = decoded.RecoveryFabricArmId + s.RecoveryFabricFriendlyName = decoded.RecoveryFabricFriendlyName + s.RecoveryNetworkFriendlyName = decoded.RecoveryNetworkFriendlyName + s.RecoveryNetworkId = decoded.RecoveryNetworkId + s.State = decoded.State + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling NetworkMappingProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["fabricSpecificSettings"]; ok { + impl, err := UnmarshalNetworkMappingFabricSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'FabricSpecificSettings' for 'NetworkMappingProperties': %+v", err) + } + s.FabricSpecificSettings = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_updatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_updatenetworkmappinginput.go new file mode 100644 index 00000000000..12c39d59aee --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_updatenetworkmappinginput.go @@ -0,0 +1,8 @@ +package replicationnetworkmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateNetworkMappingInput struct { + Properties *UpdateNetworkMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_updatenetworkmappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_updatenetworkmappinginputproperties.go new file mode 100644 index 00000000000..341408fc5db --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_updatenetworkmappinginputproperties.go @@ -0,0 +1,45 @@ +package replicationnetworkmappings + +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 UpdateNetworkMappingInputProperties struct { + FabricSpecificDetails FabricSpecificUpdateNetworkMappingInput `json:"fabricSpecificDetails"` + RecoveryFabricName *string `json:"recoveryFabricName,omitempty"` + RecoveryNetworkId *string `json:"recoveryNetworkId,omitempty"` +} + +var _ json.Unmarshaler = &UpdateNetworkMappingInputProperties{} + +func (s *UpdateNetworkMappingInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + RecoveryFabricName *string `json:"recoveryFabricName,omitempty"` + RecoveryNetworkId *string `json:"recoveryNetworkId,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.RecoveryFabricName = decoded.RecoveryFabricName + s.RecoveryNetworkId = decoded.RecoveryNetworkId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateNetworkMappingInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["fabricSpecificDetails"]; ok { + impl, err := UnmarshalFabricSpecificUpdateNetworkMappingInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'FabricSpecificDetails' for 'UpdateNetworkMappingInputProperties': %+v", err) + } + s.FabricSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtoazurecreatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtoazurecreatenetworkmappinginput.go new file mode 100644 index 00000000000..5de8410f7a0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtoazurecreatenetworkmappinginput.go @@ -0,0 +1,49 @@ +package replicationnetworkmappings + +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 _ FabricSpecificCreateNetworkMappingInput = VMmToAzureCreateNetworkMappingInput{} + +type VMmToAzureCreateNetworkMappingInput struct { + + // Fields inherited from FabricSpecificCreateNetworkMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s VMmToAzureCreateNetworkMappingInput) FabricSpecificCreateNetworkMappingInput() BaseFabricSpecificCreateNetworkMappingInputImpl { + return BaseFabricSpecificCreateNetworkMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmToAzureCreateNetworkMappingInput{} + +func (s VMmToAzureCreateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMmToAzureCreateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToAzureCreateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToAzureCreateNetworkMappingInput: %+v", err) + } + + decoded["instanceType"] = "VmmToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToAzureCreateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtoazurenetworkmappingsettings.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtoazurenetworkmappingsettings.go new file mode 100644 index 00000000000..5be8c4d6c59 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtoazurenetworkmappingsettings.go @@ -0,0 +1,49 @@ +package replicationnetworkmappings + +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 _ NetworkMappingFabricSpecificSettings = VMmToAzureNetworkMappingSettings{} + +type VMmToAzureNetworkMappingSettings struct { + + // Fields inherited from NetworkMappingFabricSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s VMmToAzureNetworkMappingSettings) NetworkMappingFabricSpecificSettings() BaseNetworkMappingFabricSpecificSettingsImpl { + return BaseNetworkMappingFabricSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmToAzureNetworkMappingSettings{} + +func (s VMmToAzureNetworkMappingSettings) MarshalJSON() ([]byte, error) { + type wrapper VMmToAzureNetworkMappingSettings + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToAzureNetworkMappingSettings: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToAzureNetworkMappingSettings: %+v", err) + } + + decoded["instanceType"] = "VmmToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToAzureNetworkMappingSettings: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtoazureupdatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtoazureupdatenetworkmappinginput.go new file mode 100644 index 00000000000..6ed764e3a78 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtoazureupdatenetworkmappinginput.go @@ -0,0 +1,49 @@ +package replicationnetworkmappings + +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 _ FabricSpecificUpdateNetworkMappingInput = VMmToAzureUpdateNetworkMappingInput{} + +type VMmToAzureUpdateNetworkMappingInput struct { + + // Fields inherited from FabricSpecificUpdateNetworkMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s VMmToAzureUpdateNetworkMappingInput) FabricSpecificUpdateNetworkMappingInput() BaseFabricSpecificUpdateNetworkMappingInputImpl { + return BaseFabricSpecificUpdateNetworkMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmToAzureUpdateNetworkMappingInput{} + +func (s VMmToAzureUpdateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMmToAzureUpdateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToAzureUpdateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToAzureUpdateNetworkMappingInput: %+v", err) + } + + decoded["instanceType"] = "VmmToAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToAzureUpdateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtovmmcreatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtovmmcreatenetworkmappinginput.go new file mode 100644 index 00000000000..3b35c972313 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtovmmcreatenetworkmappinginput.go @@ -0,0 +1,49 @@ +package replicationnetworkmappings + +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 _ FabricSpecificCreateNetworkMappingInput = VMmToVMmCreateNetworkMappingInput{} + +type VMmToVMmCreateNetworkMappingInput struct { + + // Fields inherited from FabricSpecificCreateNetworkMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s VMmToVMmCreateNetworkMappingInput) FabricSpecificCreateNetworkMappingInput() BaseFabricSpecificCreateNetworkMappingInputImpl { + return BaseFabricSpecificCreateNetworkMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmToVMmCreateNetworkMappingInput{} + +func (s VMmToVMmCreateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMmToVMmCreateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToVMmCreateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToVMmCreateNetworkMappingInput: %+v", err) + } + + decoded["instanceType"] = "VmmToVmm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToVMmCreateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtovmmnetworkmappingsettings.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtovmmnetworkmappingsettings.go new file mode 100644 index 00000000000..51bb27e4687 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtovmmnetworkmappingsettings.go @@ -0,0 +1,49 @@ +package replicationnetworkmappings + +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 _ NetworkMappingFabricSpecificSettings = VMmToVMmNetworkMappingSettings{} + +type VMmToVMmNetworkMappingSettings struct { + + // Fields inherited from NetworkMappingFabricSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s VMmToVMmNetworkMappingSettings) NetworkMappingFabricSpecificSettings() BaseNetworkMappingFabricSpecificSettingsImpl { + return BaseNetworkMappingFabricSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmToVMmNetworkMappingSettings{} + +func (s VMmToVMmNetworkMappingSettings) MarshalJSON() ([]byte, error) { + type wrapper VMmToVMmNetworkMappingSettings + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToVMmNetworkMappingSettings: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToVMmNetworkMappingSettings: %+v", err) + } + + decoded["instanceType"] = "VmmToVmm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToVMmNetworkMappingSettings: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtovmmupdatenetworkmappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtovmmupdatenetworkmappinginput.go new file mode 100644 index 00000000000..11d58df40d9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/model_vmmtovmmupdatenetworkmappinginput.go @@ -0,0 +1,49 @@ +package replicationnetworkmappings + +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 _ FabricSpecificUpdateNetworkMappingInput = VMmToVMmUpdateNetworkMappingInput{} + +type VMmToVMmUpdateNetworkMappingInput struct { + + // Fields inherited from FabricSpecificUpdateNetworkMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s VMmToVMmUpdateNetworkMappingInput) FabricSpecificUpdateNetworkMappingInput() BaseFabricSpecificUpdateNetworkMappingInputImpl { + return BaseFabricSpecificUpdateNetworkMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmToVMmUpdateNetworkMappingInput{} + +func (s VMmToVMmUpdateNetworkMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMmToVMmUpdateNetworkMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmToVMmUpdateNetworkMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmToVMmUpdateNetworkMappingInput: %+v", err) + } + + decoded["instanceType"] = "VmmToVmm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmToVMmUpdateNetworkMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/predicates.go new file mode 100644 index 00000000000..716755e52f7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/predicates.go @@ -0,0 +1,32 @@ +package replicationnetworkmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkMappingOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkMappingOperationPredicate) Matches(input NetworkMapping) 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/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/version.go new file mode 100644 index 00000000000..bd7f0bb8723 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworkmappings/version.go @@ -0,0 +1,10 @@ +package replicationnetworkmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationnetworkmappings/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/README.md new file mode 100644 index 00000000000..a936f4293b9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/README.md @@ -0,0 +1,70 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks` Documentation + +The `replicationnetworks` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationnetworks" +``` + + +### Client Initialization + +```go +client := replicationnetworks.NewReplicationNetworksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationNetworksClient.Get` + +```go +ctx := context.TODO() +id := replicationnetworks.NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName") + +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: `ReplicationNetworksClient.List` + +```go +ctx := context.TODO() +id := replicationnetworks.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// 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: `ReplicationNetworksClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationnetworks.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/client.go new file mode 100644 index 00000000000..925990ef0d7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/client.go @@ -0,0 +1,26 @@ +package replicationnetworks + +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 ReplicationNetworksClient struct { + Client *resourcemanager.Client +} + +func NewReplicationNetworksClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationNetworksClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationnetworks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationNetworksClient: %+v", err) + } + + return &ReplicationNetworksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_replicationfabric.go new file mode 100644 index 00000000000..a8c98a7e306 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_replicationfabric.go @@ -0,0 +1,139 @@ +package replicationnetworks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationFabricId{}) +} + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_replicationfabric_test.go new file mode 100644 index 00000000000..e06cfc4dd1a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationnetworks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_replicationnetwork.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_replicationnetwork.go new file mode 100644 index 00000000000..edf86f27ed8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_replicationnetwork.go @@ -0,0 +1,148 @@ +package replicationnetworks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationNetworkId{}) +} + +var _ resourceids.ResourceId = &ReplicationNetworkId{} + +// ReplicationNetworkId is a struct representing the Resource ID for a Replication Network +type ReplicationNetworkId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationNetworkName string +} + +// NewReplicationNetworkID returns a new ReplicationNetworkId struct +func NewReplicationNetworkID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationNetworkName string) ReplicationNetworkId { + return ReplicationNetworkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationNetworkName: replicationNetworkName, + } +} + +// ParseReplicationNetworkID parses 'input' into a ReplicationNetworkId +func ParseReplicationNetworkID(input string) (*ReplicationNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationNetworkIDInsensitively parses 'input' case-insensitively into a ReplicationNetworkId +// note: this method should only be used for API response data and not user input +func ParseReplicationNetworkIDInsensitively(input string) (*ReplicationNetworkId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationNetworkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationNetworkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationNetworkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationNetworkName, ok = input.Parsed["replicationNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationNetworkName", input) + } + + return nil +} + +// ValidateReplicationNetworkID checks that 'input' can be parsed as a Replication Network ID +func ValidateReplicationNetworkID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationNetworkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Network ID +func (id ReplicationNetworkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationNetworks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationNetworkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Network ID +func (id ReplicationNetworkId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationNetworks", "replicationNetworks", "replicationNetworks"), + resourceids.UserSpecifiedSegment("replicationNetworkName", "replicationNetworkName"), + } +} + +// String returns a human-readable description of this Replication Network ID +func (id ReplicationNetworkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Network Name: %q", id.ReplicationNetworkName), + } + return fmt.Sprintf("Replication Network (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_replicationnetwork_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_replicationnetwork_test.go new file mode 100644 index 00000000000..876c102db90 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_replicationnetwork_test.go @@ -0,0 +1,372 @@ +package replicationnetworks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationNetworkId{} + +func TestNewReplicationNetworkID(t *testing.T) { + id := NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationNetworkName != "replicationNetworkName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationNetworkName'", id.ReplicationNetworkName, "replicationNetworkName") + } +} + +func TestFormatReplicationNetworkID(t *testing.T) { + actual := NewReplicationNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationNetworkName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationNetworkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationNetworkName: "replicationNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + } +} + +func TestParseReplicationNetworkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationNetworkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationNetworkName: "replicationNetworkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationNetworks/replicationNetworkName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE", + Expected: &ReplicationNetworkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationNetworkName: "rEpLiCaTiOnNeTwOrKnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnNeTwOrKs/rEpLiCaTiOnNeTwOrKnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationNetworkIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationNetworkName != v.Expected.ReplicationNetworkName { + t.Fatalf("Expected %q but got %q for ReplicationNetworkName", v.Expected.ReplicationNetworkName, actual.ReplicationNetworkName) + } + + } +} + +func TestSegmentsForReplicationNetworkId(t *testing.T) { + segments := ReplicationNetworkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationNetworkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_vault.go new file mode 100644 index 00000000000..57c8e9dba03 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_vault.go @@ -0,0 +1,130 @@ +package replicationnetworks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_vault_test.go new file mode 100644 index 00000000000..4baea566f21 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationnetworks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/method_get.go new file mode 100644 index 00000000000..0c5d3fefb65 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/method_get.go @@ -0,0 +1,53 @@ +package replicationnetworks + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Network +} + +// Get ... +func (c ReplicationNetworksClient) Get(ctx context.Context, id ReplicationNetworkId) (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 Network + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/method_list.go new file mode 100644 index 00000000000..930b8eccb31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/method_list.go @@ -0,0 +1,105 @@ +package replicationnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]Network +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Network +} + +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 ReplicationNetworksClient) List(ctx context.Context, id VaultId) (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/replicationNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Network `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 ReplicationNetworksClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, NetworkOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationNetworksClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate NetworkOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Network, 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/recoveryservicessiterecovery/2025-02-01/replicationnetworks/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..88b6def873c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/method_listbyreplicationfabrics.go @@ -0,0 +1,105 @@ +package replicationnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Network +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Network +} + +type ListByReplicationFabricsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationFabricsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationFabrics ... +func (c ReplicationNetworksClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationFabricsCustomPager{}, + Path: fmt.Sprintf("%s/replicationNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Network `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationNetworksClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, NetworkOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationNetworksClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate NetworkOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]Network, 0) + + resp, err := c.ListByReplicationFabrics(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 = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/model_network.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/model_network.go new file mode 100644 index 00000000000..a55b39eacf2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/model_network.go @@ -0,0 +1,12 @@ +package replicationnetworks + +// 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 { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/model_networkproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/model_networkproperties.go new file mode 100644 index 00000000000..7a2c7204a97 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/model_networkproperties.go @@ -0,0 +1,11 @@ +package replicationnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProperties struct { + FabricType *string `json:"fabricType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/model_subnet.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/model_subnet.go new file mode 100644 index 00000000000..fed1f4919d8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/model_subnet.go @@ -0,0 +1,10 @@ +package replicationnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + AddressList *[]string `json:"addressList,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/predicates.go new file mode 100644 index 00000000000..98e4bcc158c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/predicates.go @@ -0,0 +1,32 @@ +package replicationnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkOperationPredicate) Matches(input Network) 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/recoveryservicessiterecovery/2025-02-01/replicationnetworks/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/version.go new file mode 100644 index 00000000000..8246533efa5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationnetworks/version.go @@ -0,0 +1,10 @@ +package replicationnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationnetworks/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/README.md new file mode 100644 index 00000000000..1fe81448338 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies` Documentation + +The `replicationpolicies` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationpolicies" +``` + + +### Client Initialization + +```go +client := replicationpolicies.NewReplicationPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationPoliciesClient.Create` + +```go +ctx := context.TODO() +id := replicationpolicies.NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationPolicyName") + +payload := replicationpolicies.CreatePolicyInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationPoliciesClient.Delete` + +```go +ctx := context.TODO() +id := replicationpolicies.NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationPolicyName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationPoliciesClient.Get` + +```go +ctx := context.TODO() +id := replicationpolicies.NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationPolicyName") + +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: `ReplicationPoliciesClient.List` + +```go +ctx := context.TODO() +id := replicationpolicies.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// 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: `ReplicationPoliciesClient.Update` + +```go +ctx := context.TODO() +id := replicationpolicies.NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationPolicyName") + +payload := replicationpolicies.UpdatePolicyInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/client.go new file mode 100644 index 00000000000..0ebc718b0e0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/client.go @@ -0,0 +1,26 @@ +package replicationpolicies + +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 ReplicationPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewReplicationPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationPoliciesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationpolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationPoliciesClient: %+v", err) + } + + return &ReplicationPoliciesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/constants.go new file mode 100644 index 00000000000..b57ea3f114f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/constants.go @@ -0,0 +1,51 @@ +package replicationpolicies + +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 SetMultiVMSyncStatus string + +const ( + SetMultiVMSyncStatusDisable SetMultiVMSyncStatus = "Disable" + SetMultiVMSyncStatusEnable SetMultiVMSyncStatus = "Enable" +) + +func PossibleValuesForSetMultiVMSyncStatus() []string { + return []string{ + string(SetMultiVMSyncStatusDisable), + string(SetMultiVMSyncStatusEnable), + } +} + +func (s *SetMultiVMSyncStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSetMultiVMSyncStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSetMultiVMSyncStatus(input string) (*SetMultiVMSyncStatus, error) { + vals := map[string]SetMultiVMSyncStatus{ + "disable": SetMultiVMSyncStatusDisable, + "enable": SetMultiVMSyncStatusEnable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SetMultiVMSyncStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/id_replicationpolicy.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/id_replicationpolicy.go new file mode 100644 index 00000000000..8e52815a483 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/id_replicationpolicy.go @@ -0,0 +1,139 @@ +package replicationpolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationPolicyId{}) +} + +var _ resourceids.ResourceId = &ReplicationPolicyId{} + +// ReplicationPolicyId is a struct representing the Resource ID for a Replication Policy +type ReplicationPolicyId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationPolicyName string +} + +// NewReplicationPolicyID returns a new ReplicationPolicyId struct +func NewReplicationPolicyID(subscriptionId string, resourceGroupName string, vaultName string, replicationPolicyName string) ReplicationPolicyId { + return ReplicationPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationPolicyName: replicationPolicyName, + } +} + +// ParseReplicationPolicyID parses 'input' into a ReplicationPolicyId +func ParseReplicationPolicyID(input string) (*ReplicationPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationPolicyIDInsensitively parses 'input' case-insensitively into a ReplicationPolicyId +// note: this method should only be used for API response data and not user input +func ParseReplicationPolicyIDInsensitively(input string) (*ReplicationPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationPolicyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationPolicyName, ok = input.Parsed["replicationPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationPolicyName", input) + } + + return nil +} + +// ValidateReplicationPolicyID checks that 'input' can be parsed as a Replication Policy ID +func ValidateReplicationPolicyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Policy ID +func (id ReplicationPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Policy ID +func (id ReplicationPolicyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationPolicies", "replicationPolicies", "replicationPolicies"), + resourceids.UserSpecifiedSegment("replicationPolicyName", "replicationPolicyName"), + } +} + +// String returns a human-readable description of this Replication Policy ID +func (id ReplicationPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Policy Name: %q", id.ReplicationPolicyName), + } + return fmt.Sprintf("Replication Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/id_replicationpolicy_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/id_replicationpolicy_test.go new file mode 100644 index 00000000000..a22bec723f0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/id_replicationpolicy_test.go @@ -0,0 +1,327 @@ +package replicationpolicies + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationPolicyId{} + +func TestNewReplicationPolicyID(t *testing.T) { + id := NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationPolicyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationPolicyName != "replicationPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationPolicyName'", id.ReplicationPolicyName, "replicationPolicyName") + } +} + +func TestFormatReplicationPolicyID(t *testing.T) { + actual := NewReplicationPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationPolicies/replicationPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationPolicies/replicationPolicyName", + Expected: &ReplicationPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationPolicyName: "replicationPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationPolicies/replicationPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationPolicyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationPolicyName != v.Expected.ReplicationPolicyName { + t.Fatalf("Expected %q but got %q for ReplicationPolicyName", v.Expected.ReplicationPolicyName, actual.ReplicationPolicyName) + } + + } +} + +func TestParseReplicationPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnPoLiCiEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationPolicies/replicationPolicyName", + Expected: &ReplicationPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationPolicyName: "replicationPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationPolicies/replicationPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnPoLiCiEs/rEpLiCaTiOnPoLiCyNaMe", + Expected: &ReplicationPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationPolicyName: "rEpLiCaTiOnPoLiCyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnPoLiCiEs/rEpLiCaTiOnPoLiCyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationPolicyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationPolicyName != v.Expected.ReplicationPolicyName { + t.Fatalf("Expected %q but got %q for ReplicationPolicyName", v.Expected.ReplicationPolicyName, actual.ReplicationPolicyName) + } + + } +} + +func TestSegmentsForReplicationPolicyId(t *testing.T) { + segments := ReplicationPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationPolicyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/id_vault.go new file mode 100644 index 00000000000..e16dd3da492 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/id_vault.go @@ -0,0 +1,130 @@ +package replicationpolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/id_vault_test.go new file mode 100644 index 00000000000..8c7119dc1f2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationpolicies + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_create.go new file mode 100644 index 00000000000..2fa363134e7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_create.go @@ -0,0 +1,75 @@ +package replicationpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Policy +} + +// Create ... +func (c ReplicationPoliciesClient) Create(ctx context.Context, id ReplicationPolicyId, input CreatePolicyInput) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationPoliciesClient) CreateThenPoll(ctx context.Context, id ReplicationPolicyId, input CreatePolicyInput) 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/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_delete.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_delete.go new file mode 100644 index 00000000000..4e3017160f7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_delete.go @@ -0,0 +1,70 @@ +package replicationpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 ReplicationPoliciesClient) Delete(ctx context.Context, id ReplicationPolicyId) (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 ReplicationPoliciesClient) DeleteThenPoll(ctx context.Context, id ReplicationPolicyId) 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/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_get.go new file mode 100644 index 00000000000..711498c7141 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_get.go @@ -0,0 +1,53 @@ +package replicationpolicies + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Policy +} + +// Get ... +func (c ReplicationPoliciesClient) Get(ctx context.Context, id ReplicationPolicyId) (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 Policy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_list.go new file mode 100644 index 00000000000..28ba613b34b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_list.go @@ -0,0 +1,105 @@ +package replicationpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]Policy +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Policy +} + +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 ReplicationPoliciesClient) List(ctx context.Context, id VaultId) (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/replicationPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Policy `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 ReplicationPoliciesClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, PolicyOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationPoliciesClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate PolicyOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Policy, 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/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_update.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_update.go new file mode 100644 index 00000000000..91f76915b75 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/method_update.go @@ -0,0 +1,75 @@ +package replicationpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Policy +} + +// Update ... +func (c ReplicationPoliciesClient) Update(ctx context.Context, id ReplicationPolicyId, input UpdatePolicyInput) (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 ReplicationPoliciesClient) UpdateThenPoll(ctx context.Context, id ReplicationPolicyId, input UpdatePolicyInput) 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/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_a2acrossclustermigrationpolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_a2acrossclustermigrationpolicycreationinput.go new file mode 100644 index 00000000000..fb391222f09 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_a2acrossclustermigrationpolicycreationinput.go @@ -0,0 +1,49 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificInput = A2ACrossClusterMigrationPolicyCreationInput{} + +type A2ACrossClusterMigrationPolicyCreationInput struct { + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ACrossClusterMigrationPolicyCreationInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ACrossClusterMigrationPolicyCreationInput{} + +func (s A2ACrossClusterMigrationPolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationPolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationPolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationPolicyCreationInput: %+v", err) + } + + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationPolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_a2apolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_a2apolicycreationinput.go new file mode 100644 index 00000000000..7e7b12aefc1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_a2apolicycreationinput.go @@ -0,0 +1,53 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificInput = A2APolicyCreationInput{} + +type A2APolicyCreationInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2APolicyCreationInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2APolicyCreationInput{} + +func (s A2APolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper A2APolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2APolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2APolicyCreationInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2APolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_a2apolicydetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_a2apolicydetails.go new file mode 100644 index 00000000000..de32bcd7ca6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_a2apolicydetails.go @@ -0,0 +1,54 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificDetails = A2APolicyDetails{} + +type A2APolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s A2APolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2APolicyDetails{} + +func (s A2APolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper A2APolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2APolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2APolicyDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2APolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_createpolicyinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_createpolicyinput.go new file mode 100644 index 00000000000..a1cb3c60fe8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_createpolicyinput.go @@ -0,0 +1,8 @@ +package replicationpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreatePolicyInput struct { + Properties *CreatePolicyInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_createpolicyinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_createpolicyinputproperties.go new file mode 100644 index 00000000000..ed5af5dd2d4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_createpolicyinputproperties.go @@ -0,0 +1,33 @@ +package replicationpolicies + +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 CreatePolicyInputProperties struct { + ProviderSpecificInput PolicyProviderSpecificInput `json:"providerSpecificInput"` +} + +var _ json.Unmarshaler = &CreatePolicyInputProperties{} + +func (s *CreatePolicyInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreatePolicyInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + impl, err := UnmarshalPolicyProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificInput' for 'CreatePolicyInputProperties': %+v", err) + } + s.ProviderSpecificInput = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicaazurepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicaazurepolicydetails.go new file mode 100644 index 00000000000..09456d1aa8f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicaazurepolicydetails.go @@ -0,0 +1,55 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificDetails = HyperVReplicaAzurePolicyDetails{} + +type HyperVReplicaAzurePolicyDetails struct { + ActiveStorageAccountId *string `json:"activeStorageAccountId,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Encryption *string `json:"encryption,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPointHistoryDurationInHours *int64 `json:"recoveryPointHistoryDurationInHours,omitempty"` + ReplicationInterval *int64 `json:"replicationInterval,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzurePolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzurePolicyDetails{} + +func (s HyperVReplicaAzurePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzurePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzurePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzurePolicyDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzurePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicaazurepolicyinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicaazurepolicyinput.go new file mode 100644 index 00000000000..e186a0c6ca4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicaazurepolicyinput.go @@ -0,0 +1,54 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificInput = HyperVReplicaAzurePolicyInput{} + +type HyperVReplicaAzurePolicyInput struct { + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPointHistoryDuration *int64 `json:"recoveryPointHistoryDuration,omitempty"` + ReplicationInterval *int64 `json:"replicationInterval,omitempty"` + StorageAccounts *[]string `json:"storageAccounts,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzurePolicyInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzurePolicyInput{} + +func (s HyperVReplicaAzurePolicyInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzurePolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzurePolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzurePolicyInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzurePolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicabasepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicabasepolicydetails.go new file mode 100644 index 00000000000..54e54a624bc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicabasepolicydetails.go @@ -0,0 +1,59 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificDetails = HyperVReplicaBasePolicyDetails{} + +type HyperVReplicaBasePolicyDetails struct { + AllowedAuthenticationType *int64 `json:"allowedAuthenticationType,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPoints *int64 `json:"recoveryPoints,omitempty"` + ReplicaDeletionOption *string `json:"replicaDeletionOption,omitempty"` + ReplicationPort *int64 `json:"replicationPort,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaBasePolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaBasePolicyDetails{} + +func (s HyperVReplicaBasePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBasePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBasePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBasePolicyDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaBasePolicyDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBasePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicabluepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicabluepolicydetails.go new file mode 100644 index 00000000000..2fcb7bb9422 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicabluepolicydetails.go @@ -0,0 +1,60 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificDetails = HyperVReplicaBluePolicyDetails{} + +type HyperVReplicaBluePolicyDetails struct { + AllowedAuthenticationType *int64 `json:"allowedAuthenticationType,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPoints *int64 `json:"recoveryPoints,omitempty"` + ReplicaDeletionOption *string `json:"replicaDeletionOption,omitempty"` + ReplicationFrequencyInSeconds *int64 `json:"replicationFrequencyInSeconds,omitempty"` + ReplicationPort *int64 `json:"replicationPort,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaBluePolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaBluePolicyDetails{} + +func (s HyperVReplicaBluePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBluePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBluePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBluePolicyDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012R2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBluePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicabluepolicyinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicabluepolicyinput.go new file mode 100644 index 00000000000..408e43857b3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicabluepolicyinput.go @@ -0,0 +1,50 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificInput = HyperVReplicaBluePolicyInput{} + +type HyperVReplicaBluePolicyInput struct { + ReplicationFrequencyInSeconds *int64 `json:"replicationFrequencyInSeconds,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaBluePolicyInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaBluePolicyInput{} + +func (s HyperVReplicaBluePolicyInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBluePolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBluePolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBluePolicyInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012R2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBluePolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicapolicydetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicapolicydetails.go new file mode 100644 index 00000000000..13f18ff2e19 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicapolicydetails.go @@ -0,0 +1,59 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificDetails = HyperVReplicaPolicyDetails{} + +type HyperVReplicaPolicyDetails struct { + AllowedAuthenticationType *int64 `json:"allowedAuthenticationType,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPoints *int64 `json:"recoveryPoints,omitempty"` + ReplicaDeletionOption *string `json:"replicaDeletionOption,omitempty"` + ReplicationPort *int64 `json:"replicationPort,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaPolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaPolicyDetails{} + +func (s HyperVReplicaPolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaPolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaPolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaPolicyDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaPolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicapolicyinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicapolicyinput.go new file mode 100644 index 00000000000..100c9e1d9f4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_hypervreplicapolicyinput.go @@ -0,0 +1,59 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificInput = HyperVReplicaPolicyInput{} + +type HyperVReplicaPolicyInput struct { + AllowedAuthenticationType *int64 `json:"allowedAuthenticationType,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int64 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + RecoveryPoints *int64 `json:"recoveryPoints,omitempty"` + ReplicaDeletion *string `json:"replicaDeletion,omitempty"` + ReplicationPort *int64 `json:"replicationPort,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaPolicyInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaPolicyInput{} + +func (s HyperVReplicaPolicyInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaPolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaPolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaPolicyInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaPolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmageazurev2policydetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmageazurev2policydetails.go new file mode 100644 index 00000000000..e8c78d43db9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmageazurev2policydetails.go @@ -0,0 +1,54 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificDetails = InMageAzureV2PolicyDetails{} + +type InMageAzureV2PolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2PolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2PolicyDetails{} + +func (s InMageAzureV2PolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2PolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2PolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2PolicyDetails: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2PolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmageazurev2policyinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmageazurev2policyinput.go new file mode 100644 index 00000000000..1d72287fec4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmageazurev2policyinput.go @@ -0,0 +1,54 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificInput = InMageAzureV2PolicyInput{} + +type InMageAzureV2PolicyInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2PolicyInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2PolicyInput{} + +func (s InMageAzureV2PolicyInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2PolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2PolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2PolicyInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2PolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagebasepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagebasepolicydetails.go new file mode 100644 index 00000000000..cea2dc818ca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagebasepolicydetails.go @@ -0,0 +1,53 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificDetails = InMageBasePolicyDetails{} + +type InMageBasePolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageBasePolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageBasePolicyDetails{} + +func (s InMageBasePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageBasePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageBasePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageBasePolicyDetails: %+v", err) + } + + decoded["instanceType"] = "InMageBasePolicyDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageBasePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagepolicydetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagepolicydetails.go new file mode 100644 index 00000000000..785e7acebcf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagepolicydetails.go @@ -0,0 +1,53 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificDetails = InMagePolicyDetails{} + +type InMagePolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMagePolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMagePolicyDetails{} + +func (s InMagePolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMagePolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMagePolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMagePolicyDetails: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMagePolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagepolicyinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagepolicyinput.go new file mode 100644 index 00000000000..8e2b3d62d36 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagepolicyinput.go @@ -0,0 +1,53 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificInput = InMagePolicyInput{} + +type InMagePolicyInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + RecoveryPointThresholdInMinutes *int64 `json:"recoveryPointThresholdInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMagePolicyInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMagePolicyInput{} + +func (s InMagePolicyInput) MarshalJSON() ([]byte, error) { + type wrapper InMagePolicyInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMagePolicyInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMagePolicyInput: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMagePolicyInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagercmfailbackpolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagercmfailbackpolicycreationinput.go new file mode 100644 index 00000000000..7f9d9eff596 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagercmfailbackpolicycreationinput.go @@ -0,0 +1,51 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificInput = InMageRcmFailbackPolicyCreationInput{} + +type InMageRcmFailbackPolicyCreationInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFailbackPolicyCreationInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFailbackPolicyCreationInput{} + +func (s InMageRcmFailbackPolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackPolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackPolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackPolicyCreationInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackPolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagercmfailbackpolicydetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagercmfailbackpolicydetails.go new file mode 100644 index 00000000000..98177d4e134 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagercmfailbackpolicydetails.go @@ -0,0 +1,51 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificDetails = InMageRcmFailbackPolicyDetails{} + +type InMageRcmFailbackPolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFailbackPolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFailbackPolicyDetails{} + +func (s InMageRcmFailbackPolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackPolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackPolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackPolicyDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackPolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagercmpolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagercmpolicycreationinput.go new file mode 100644 index 00000000000..61e6e84a628 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagercmpolicycreationinput.go @@ -0,0 +1,53 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificInput = InMageRcmPolicyCreationInput{} + +type InMageRcmPolicyCreationInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + EnableMultiVMSync *string `json:"enableMultiVmSync,omitempty"` + RecoveryPointHistoryInMinutes *int64 `json:"recoveryPointHistoryInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmPolicyCreationInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmPolicyCreationInput{} + +func (s InMageRcmPolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmPolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmPolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmPolicyCreationInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmPolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagercmpolicydetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagercmpolicydetails.go new file mode 100644 index 00000000000..589bab17807 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_inmagercmpolicydetails.go @@ -0,0 +1,53 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificDetails = InMageRcmPolicyDetails{} + +type InMageRcmPolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + EnableMultiVMSync *string `json:"enableMultiVmSync,omitempty"` + RecoveryPointHistoryInMinutes *int64 `json:"recoveryPointHistoryInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmPolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmPolicyDetails{} + +func (s InMageRcmPolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmPolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmPolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmPolicyDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmPolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_policy.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_policy.go new file mode 100644 index 00000000000..f57b4a8530b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_policy.go @@ -0,0 +1,12 @@ +package replicationpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Policy struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PolicyProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_policyproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_policyproperties.go new file mode 100644 index 00000000000..de051df248b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_policyproperties.go @@ -0,0 +1,42 @@ +package replicationpolicies + +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 PolicyProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + ProviderSpecificDetails PolicyProviderSpecificDetails `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &PolicyProperties{} + +func (s *PolicyProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FriendlyName *string `json:"friendlyName,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FriendlyName = decoded.FriendlyName + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling PolicyProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalPolicyProviderSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'PolicyProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_policyproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_policyproviderspecificdetails.go new file mode 100644 index 00000000000..65fecd406b4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_policyproviderspecificdetails.go @@ -0,0 +1,155 @@ +package replicationpolicies + +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 PolicyProviderSpecificDetails interface { + PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl +} + +var _ PolicyProviderSpecificDetails = BasePolicyProviderSpecificDetailsImpl{} + +type BasePolicyProviderSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BasePolicyProviderSpecificDetailsImpl) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return s +} + +var _ PolicyProviderSpecificDetails = RawPolicyProviderSpecificDetailsImpl{} + +// RawPolicyProviderSpecificDetailsImpl 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 RawPolicyProviderSpecificDetailsImpl struct { + policyProviderSpecificDetails BasePolicyProviderSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawPolicyProviderSpecificDetailsImpl) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return s.policyProviderSpecificDetails +} + +func UnmarshalPolicyProviderSpecificDetailsImplementation(input []byte) (PolicyProviderSpecificDetails, 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 PolicyProviderSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2APolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2APolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzurePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzurePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaBasePolicyDetails") { + var out HyperVReplicaBasePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBasePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012R2") { + var out HyperVReplicaBluePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBluePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012") { + var out HyperVReplicaPolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaPolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2PolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2PolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageBasePolicyDetails") { + var out InMageBasePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageBasePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMagePolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMagePolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackPolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackPolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmPolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmPolicyDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtPolicyDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtPolicyDetails: %+v", err) + } + return out, nil + } + + var parent BasePolicyProviderSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BasePolicyProviderSpecificDetailsImpl: %+v", err) + } + + return RawPolicyProviderSpecificDetailsImpl{ + policyProviderSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_policyproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_policyproviderspecificinput.go new file mode 100644 index 00000000000..b705d0e88c8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_policyproviderspecificinput.go @@ -0,0 +1,139 @@ +package replicationpolicies + +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 PolicyProviderSpecificInput interface { + PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl +} + +var _ PolicyProviderSpecificInput = BasePolicyProviderSpecificInputImpl{} + +type BasePolicyProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BasePolicyProviderSpecificInputImpl) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return s +} + +var _ PolicyProviderSpecificInput = RawPolicyProviderSpecificInputImpl{} + +// RawPolicyProviderSpecificInputImpl 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 RawPolicyProviderSpecificInputImpl struct { + policyProviderSpecificInput BasePolicyProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawPolicyProviderSpecificInputImpl) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return s.policyProviderSpecificInput +} + +func UnmarshalPolicyProviderSpecificInputImplementation(input []byte) (PolicyProviderSpecificInput, 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 PolicyProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationPolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationPolicyCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2APolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2APolicyCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzurePolicyInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzurePolicyInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012") { + var out HyperVReplicaPolicyInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaPolicyInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2PolicyInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2PolicyInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMagePolicyInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMagePolicyInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackPolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackPolicyCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmPolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmPolicyCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtPolicyCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtPolicyCreationInput: %+v", err) + } + return out, nil + } + + var parent BasePolicyProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BasePolicyProviderSpecificInputImpl: %+v", err) + } + + return RawPolicyProviderSpecificInputImpl{ + policyProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_updatepolicyinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_updatepolicyinput.go new file mode 100644 index 00000000000..ca0f0a2c86e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_updatepolicyinput.go @@ -0,0 +1,8 @@ +package replicationpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdatePolicyInput struct { + Properties *UpdatePolicyInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_updatepolicyinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_updatepolicyinputproperties.go new file mode 100644 index 00000000000..ba3876b3319 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_updatepolicyinputproperties.go @@ -0,0 +1,33 @@ +package replicationpolicies + +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 UpdatePolicyInputProperties struct { + ReplicationProviderSettings PolicyProviderSpecificInput `json:"replicationProviderSettings"` +} + +var _ json.Unmarshaler = &UpdatePolicyInputProperties{} + +func (s *UpdatePolicyInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdatePolicyInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["replicationProviderSettings"]; ok { + impl, err := UnmarshalPolicyProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ReplicationProviderSettings' for 'UpdatePolicyInputProperties': %+v", err) + } + s.ReplicationProviderSettings = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_vmwarecbtpolicycreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_vmwarecbtpolicycreationinput.go new file mode 100644 index 00000000000..eaac5dcf2e3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_vmwarecbtpolicycreationinput.go @@ -0,0 +1,52 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificInput = VMwareCbtPolicyCreationInput{} + +type VMwareCbtPolicyCreationInput struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + RecoveryPointHistoryInMinutes *int64 `json:"recoveryPointHistoryInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtPolicyCreationInput) PolicyProviderSpecificInput() BasePolicyProviderSpecificInputImpl { + return BasePolicyProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtPolicyCreationInput{} + +func (s VMwareCbtPolicyCreationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtPolicyCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtPolicyCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtPolicyCreationInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtPolicyCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_vmwarecbtpolicydetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_vmwarecbtpolicydetails.go new file mode 100644 index 00000000000..d1398f83ff1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/model_vmwarecbtpolicydetails.go @@ -0,0 +1,52 @@ +package replicationpolicies + +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 _ PolicyProviderSpecificDetails = VMwareCbtPolicyDetails{} + +type VMwareCbtPolicyDetails struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + RecoveryPointHistoryInMinutes *int64 `json:"recoveryPointHistoryInMinutes,omitempty"` + + // Fields inherited from PolicyProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtPolicyDetails) PolicyProviderSpecificDetails() BasePolicyProviderSpecificDetailsImpl { + return BasePolicyProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtPolicyDetails{} + +func (s VMwareCbtPolicyDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtPolicyDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtPolicyDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtPolicyDetails: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtPolicyDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/predicates.go new file mode 100644 index 00000000000..3cb066948b0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/predicates.go @@ -0,0 +1,32 @@ +package replicationpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p PolicyOperationPredicate) Matches(input Policy) 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/recoveryservicessiterecovery/2025-02-01/replicationpolicies/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/version.go new file mode 100644 index 00000000000..20941e2bd8e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationpolicies/version.go @@ -0,0 +1,10 @@ +package replicationpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationpolicies/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/README.md new file mode 100644 index 00000000000..5006f52fcfe --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems` Documentation + +The `replicationprotectableitems` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems" +``` + + +### Client Initialization + +```go +client := replicationprotectableitems.NewReplicationProtectableItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectableItemsClient.Get` + +```go +ctx := context.TODO() +id := replicationprotectableitems.NewReplicationProtectableItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectableItemName") + +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: `ReplicationProtectableItemsClient.ListByReplicationProtectionContainers` + +```go +ctx := context.TODO() +id := replicationprotectableitems.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +// alternatively `client.ListByReplicationProtectionContainers(ctx, id, replicationprotectableitems.DefaultListByReplicationProtectionContainersOperationOptions())` can be used to do batched pagination +items, err := client.ListByReplicationProtectionContainersComplete(ctx, id, replicationprotectableitems.DefaultListByReplicationProtectionContainersOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/client.go new file mode 100644 index 00000000000..0fe8f850abb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/client.go @@ -0,0 +1,26 @@ +package replicationprotectableitems + +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 ReplicationProtectableItemsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectableItemsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectableItemsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationprotectableitems", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectableItemsClient: %+v", err) + } + + return &ReplicationProtectableItemsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/constants.go new file mode 100644 index 00000000000..ba651c88667 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/constants.go @@ -0,0 +1,95 @@ +package replicationprotectableitems + +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 HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type PresenceStatus string + +const ( + PresenceStatusNotPresent PresenceStatus = "NotPresent" + PresenceStatusPresent PresenceStatus = "Present" + PresenceStatusUnknown PresenceStatus = "Unknown" +) + +func PossibleValuesForPresenceStatus() []string { + return []string{ + string(PresenceStatusNotPresent), + string(PresenceStatusPresent), + string(PresenceStatusUnknown), + } +} + +func (s *PresenceStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePresenceStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePresenceStatus(input string) (*PresenceStatus, error) { + vals := map[string]PresenceStatus{ + "notpresent": PresenceStatusNotPresent, + "present": PresenceStatusPresent, + "unknown": PresenceStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PresenceStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/id_replicationprotectableitem.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/id_replicationprotectableitem.go new file mode 100644 index 00000000000..5688af5bd49 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/id_replicationprotectableitem.go @@ -0,0 +1,157 @@ +package replicationprotectableitems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectableItemId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectableItemId{} + +// ReplicationProtectableItemId is a struct representing the Resource ID for a Replication Protectable Item +type ReplicationProtectableItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectableItemName string +} + +// NewReplicationProtectableItemID returns a new ReplicationProtectableItemId struct +func NewReplicationProtectableItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectableItemName string) ReplicationProtectableItemId { + return ReplicationProtectableItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectableItemName: replicationProtectableItemName, + } +} + +// ParseReplicationProtectableItemID parses 'input' into a ReplicationProtectableItemId +func ParseReplicationProtectableItemID(input string) (*ReplicationProtectableItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectableItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectableItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectableItemIDInsensitively parses 'input' case-insensitively into a ReplicationProtectableItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectableItemIDInsensitively(input string) (*ReplicationProtectableItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectableItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectableItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectableItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectableItemName, ok = input.Parsed["replicationProtectableItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectableItemName", input) + } + + return nil +} + +// ValidateReplicationProtectableItemID checks that 'input' can be parsed as a Replication Protectable Item ID +func ValidateReplicationProtectableItemID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectableItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protectable Item ID +func (id ReplicationProtectableItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectableItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectableItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protectable Item ID +func (id ReplicationProtectableItemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectableItems", "replicationProtectableItems", "replicationProtectableItems"), + resourceids.UserSpecifiedSegment("replicationProtectableItemName", "replicationProtectableItemName"), + } +} + +// String returns a human-readable description of this Replication Protectable Item ID +func (id ReplicationProtectableItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protectable Item Name: %q", id.ReplicationProtectableItemName), + } + return fmt.Sprintf("Replication Protectable Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/id_replicationprotectableitem_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/id_replicationprotectableitem_test.go new file mode 100644 index 00000000000..5ca442edaf4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/id_replicationprotectableitem_test.go @@ -0,0 +1,417 @@ +package replicationprotectableitems + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectableItemId{} + +func TestNewReplicationProtectableItemID(t *testing.T) { + id := NewReplicationProtectableItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectableItemName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectableItemName != "replicationProtectableItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectableItemName'", id.ReplicationProtectableItemName, "replicationProtectableItemName") + } +} + +func TestFormatReplicationProtectableItemID(t *testing.T) { + actual := NewReplicationProtectableItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectableItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectableItems/replicationProtectableItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectableItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectableItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectableItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectableItems/replicationProtectableItemName", + Expected: &ReplicationProtectableItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectableItemName: "replicationProtectableItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectableItems/replicationProtectableItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectableItemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectableItemName != v.Expected.ReplicationProtectableItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectableItemName", v.Expected.ReplicationProtectableItemName, actual.ReplicationProtectableItemName) + } + + } +} + +func TestParseReplicationProtectableItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectableItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectableItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTaBlEiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectableItems/replicationProtectableItemName", + Expected: &ReplicationProtectableItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectableItemName: "replicationProtectableItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectableItems/replicationProtectableItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTaBlEiTeMs/rEpLiCaTiOnPrOtEcTaBlEiTeMnAmE", + Expected: &ReplicationProtectableItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectableItemName: "rEpLiCaTiOnPrOtEcTaBlEiTeMnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTaBlEiTeMs/rEpLiCaTiOnPrOtEcTaBlEiTeMnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectableItemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectableItemName != v.Expected.ReplicationProtectableItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectableItemName", v.Expected.ReplicationProtectableItemName, actual.ReplicationProtectableItemName) + } + + } +} + +func TestSegmentsForReplicationProtectableItemId(t *testing.T) { + segments := ReplicationProtectableItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectableItemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..f23f4dd7edc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/id_replicationprotectioncontainer.go @@ -0,0 +1,148 @@ +package replicationprotectableitems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectionContainerId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..34d92bb2295 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationprotectableitems + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/method_get.go new file mode 100644 index 00000000000..c002604133f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/method_get.go @@ -0,0 +1,53 @@ +package replicationprotectableitems + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ProtectableItem +} + +// Get ... +func (c ReplicationProtectableItemsClient) Get(ctx context.Context, id ReplicationProtectableItemId) (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 ProtectableItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/method_listbyreplicationprotectioncontainers.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/method_listbyreplicationprotectioncontainers.go new file mode 100644 index 00000000000..156271c76d1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/method_listbyreplicationprotectioncontainers.go @@ -0,0 +1,138 @@ +package replicationprotectableitems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationProtectionContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProtectableItem +} + +type ListByReplicationProtectionContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectableItem +} + +type ListByReplicationProtectionContainersOperationOptions struct { + Filter *string + Take *string +} + +func DefaultListByReplicationProtectionContainersOperationOptions() ListByReplicationProtectionContainersOperationOptions { + return ListByReplicationProtectionContainersOperationOptions{} +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByReplicationProtectionContainersOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Take != nil { + out.Append("$take", fmt.Sprintf("%v", *o.Take)) + } + return &out +} + +type ListByReplicationProtectionContainersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectionContainersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectionContainers ... +func (c ReplicationProtectableItemsClient) ListByReplicationProtectionContainers(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions) (result ListByReplicationProtectionContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByReplicationProtectionContainersCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectableItems", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProtectableItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionContainersComplete retrieves all the results into a single object +func (c ReplicationProtectableItemsClient) ListByReplicationProtectionContainersComplete(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions) (ListByReplicationProtectionContainersCompleteResult, error) { + return c.ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx, id, options, ProtectableItemOperationPredicate{}) +} + +// ListByReplicationProtectionContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectableItemsClient) ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionContainerId, options ListByReplicationProtectionContainersOperationOptions, predicate ProtectableItemOperationPredicate) (result ListByReplicationProtectionContainersCompleteResult, err error) { + items := make([]ProtectableItem, 0) + + resp, err := c.ListByReplicationProtectionContainers(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 = ListByReplicationProtectionContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_configurationsettings.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_configurationsettings.go new file mode 100644 index 00000000000..1bd6d6c2b38 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_configurationsettings.go @@ -0,0 +1,91 @@ +package replicationprotectableitems + +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 ConfigurationSettings interface { + ConfigurationSettings() BaseConfigurationSettingsImpl +} + +var _ ConfigurationSettings = BaseConfigurationSettingsImpl{} + +type BaseConfigurationSettingsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseConfigurationSettingsImpl) ConfigurationSettings() BaseConfigurationSettingsImpl { + return s +} + +var _ ConfigurationSettings = RawConfigurationSettingsImpl{} + +// RawConfigurationSettingsImpl 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 RawConfigurationSettingsImpl struct { + configurationSettings BaseConfigurationSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawConfigurationSettingsImpl) ConfigurationSettings() BaseConfigurationSettingsImpl { + return s.configurationSettings +} + +func UnmarshalConfigurationSettingsImplementation(input []byte) (ConfigurationSettings, 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 ConfigurationSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "HyperVVirtualMachine") { + var out HyperVVirtualMachineDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVVirtualMachineDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ReplicationGroupDetails") { + var out ReplicationGroupDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ReplicationGroupDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareVirtualMachine") { + var out VMwareVirtualMachineDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareVirtualMachineDetails: %+v", err) + } + return out, nil + } + + var parent BaseConfigurationSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseConfigurationSettingsImpl: %+v", err) + } + + return RawConfigurationSettingsImpl{ + configurationSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_diskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_diskdetails.go new file mode 100644 index 00000000000..f418a8a199a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_diskdetails.go @@ -0,0 +1,11 @@ +package replicationprotectableitems + +// 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 { + MaxSizeMB *int64 `json:"maxSizeMB,omitempty"` + VhdId *string `json:"vhdId,omitempty"` + VhdName *string `json:"vhdName,omitempty"` + VhdType *string `json:"vhdType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_diskvolumedetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_diskvolumedetails.go new file mode 100644 index 00000000000..a1807b2e5d9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_diskvolumedetails.go @@ -0,0 +1,9 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskVolumeDetails struct { + Label *string `json:"label,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_healtherror.go new file mode 100644 index 00000000000..dd836fd7405 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationprotectableitems + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_hypervvirtualmachinedetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_hypervvirtualmachinedetails.go new file mode 100644 index 00000000000..d9b640d45d9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_hypervvirtualmachinedetails.go @@ -0,0 +1,57 @@ +package replicationprotectableitems + +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 _ ConfigurationSettings = HyperVVirtualMachineDetails{} + +type HyperVVirtualMachineDetails struct { + DiskDetails *[]DiskDetails `json:"diskDetails,omitempty"` + Generation *string `json:"generation,omitempty"` + HasFibreChannelAdapter *PresenceStatus `json:"hasFibreChannelAdapter,omitempty"` + HasPhysicalDisk *PresenceStatus `json:"hasPhysicalDisk,omitempty"` + HasSharedVhd *PresenceStatus `json:"hasSharedVhd,omitempty"` + HyperVHostId *string `json:"hyperVHostId,omitempty"` + OsDetails *OSDetails `json:"osDetails,omitempty"` + SourceItemId *string `json:"sourceItemId,omitempty"` + + // Fields inherited from ConfigurationSettings + + InstanceType string `json:"instanceType"` +} + +func (s HyperVVirtualMachineDetails) ConfigurationSettings() BaseConfigurationSettingsImpl { + return BaseConfigurationSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVVirtualMachineDetails{} + +func (s HyperVVirtualMachineDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVVirtualMachineDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVVirtualMachineDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVVirtualMachineDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVVirtualMachine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVVirtualMachineDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_inmagediskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_inmagediskdetails.go new file mode 100644 index 00000000000..a4233f28136 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_inmagediskdetails.go @@ -0,0 +1,13 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageDiskDetails struct { + DiskConfiguration *string `json:"diskConfiguration,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskSizeInMB *string `json:"diskSizeInMB,omitempty"` + DiskType *string `json:"diskType,omitempty"` + VolumeList *[]DiskVolumeDetails `json:"volumeList,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_innerhealtherror.go new file mode 100644 index 00000000000..ee306e7b230 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationprotectableitems + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_osdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_osdetails.go new file mode 100644 index 00000000000..cfe4ba2336b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_osdetails.go @@ -0,0 +1,14 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSDetails struct { + OSMajorVersion *string `json:"oSMajorVersion,omitempty"` + OSMinorVersion *string `json:"oSMinorVersion,omitempty"` + OSVersion *string `json:"oSVersion,omitempty"` + OsEdition *string `json:"osEdition,omitempty"` + OsType *string `json:"osType,omitempty"` + ProductType *string `json:"productType,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_protectableitem.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_protectableitem.go new file mode 100644 index 00000000000..f2996c6b514 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_protectableitem.go @@ -0,0 +1,12 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectableItem struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProtectableItemProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_protectableitemproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_protectableitemproperties.go new file mode 100644 index 00000000000..525d23bc6b1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_protectableitemproperties.go @@ -0,0 +1,57 @@ +package replicationprotectableitems + +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 ProtectableItemProperties struct { + CustomDetails ConfigurationSettings `json:"customDetails"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionReadinessErrors *[]string `json:"protectionReadinessErrors,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationProtectedItemId *string `json:"replicationProtectedItemId,omitempty"` + SupportedReplicationProviders *[]string `json:"supportedReplicationProviders,omitempty"` +} + +var _ json.Unmarshaler = &ProtectableItemProperties{} + +func (s *ProtectableItemProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionReadinessErrors *[]string `json:"protectionReadinessErrors,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationProtectedItemId *string `json:"replicationProtectedItemId,omitempty"` + SupportedReplicationProviders *[]string `json:"supportedReplicationProviders,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FriendlyName = decoded.FriendlyName + s.ProtectionReadinessErrors = decoded.ProtectionReadinessErrors + s.ProtectionStatus = decoded.ProtectionStatus + s.RecoveryServicesProviderId = decoded.RecoveryServicesProviderId + s.ReplicationProtectedItemId = decoded.ReplicationProtectedItemId + s.SupportedReplicationProviders = decoded.SupportedReplicationProviders + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectableItemProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := UnmarshalConfigurationSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'ProtectableItemProperties': %+v", err) + } + s.CustomDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_replicationgroupdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_replicationgroupdetails.go new file mode 100644 index 00000000000..2ba6c0e2112 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_replicationgroupdetails.go @@ -0,0 +1,49 @@ +package replicationprotectableitems + +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 _ ConfigurationSettings = ReplicationGroupDetails{} + +type ReplicationGroupDetails struct { + + // Fields inherited from ConfigurationSettings + + InstanceType string `json:"instanceType"` +} + +func (s ReplicationGroupDetails) ConfigurationSettings() BaseConfigurationSettingsImpl { + return BaseConfigurationSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = ReplicationGroupDetails{} + +func (s ReplicationGroupDetails) MarshalJSON() ([]byte, error) { + type wrapper ReplicationGroupDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ReplicationGroupDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ReplicationGroupDetails: %+v", err) + } + + decoded["instanceType"] = "ReplicationGroupDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ReplicationGroupDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_vmmvirtualmachinedetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_vmmvirtualmachinedetails.go new file mode 100644 index 00000000000..a23bbd99d96 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_vmmvirtualmachinedetails.go @@ -0,0 +1,49 @@ +package replicationprotectableitems + +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 _ ConfigurationSettings = VMmVirtualMachineDetails{} + +type VMmVirtualMachineDetails struct { + + // Fields inherited from ConfigurationSettings + + InstanceType string `json:"instanceType"` +} + +func (s VMmVirtualMachineDetails) ConfigurationSettings() BaseConfigurationSettingsImpl { + return BaseConfigurationSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMmVirtualMachineDetails{} + +func (s VMmVirtualMachineDetails) MarshalJSON() ([]byte, error) { + type wrapper VMmVirtualMachineDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMmVirtualMachineDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMmVirtualMachineDetails: %+v", err) + } + + decoded["instanceType"] = "VmmVirtualMachine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMmVirtualMachineDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_vmwarevirtualmachinedetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_vmwarevirtualmachinedetails.go new file mode 100644 index 00000000000..e372e550548 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/model_vmwarevirtualmachinedetails.go @@ -0,0 +1,59 @@ +package replicationprotectableitems + +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 _ ConfigurationSettings = VMwareVirtualMachineDetails{} + +type VMwareVirtualMachineDetails struct { + AgentGeneratedId *string `json:"agentGeneratedId,omitempty"` + AgentInstalled *string `json:"agentInstalled,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + DiskDetails *[]InMageDiskDetails `json:"diskDetails,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + OsType *string `json:"osType,omitempty"` + PoweredOn *string `json:"poweredOn,omitempty"` + VCenterInfrastructureId *string `json:"vCenterInfrastructureId,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` + + // Fields inherited from ConfigurationSettings + + InstanceType string `json:"instanceType"` +} + +func (s VMwareVirtualMachineDetails) ConfigurationSettings() BaseConfigurationSettingsImpl { + return BaseConfigurationSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareVirtualMachineDetails{} + +func (s VMwareVirtualMachineDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareVirtualMachineDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareVirtualMachineDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareVirtualMachineDetails: %+v", err) + } + + decoded["instanceType"] = "VMwareVirtualMachine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareVirtualMachineDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/predicates.go new file mode 100644 index 00000000000..cd7684d6433 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/predicates.go @@ -0,0 +1,32 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectableItemOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectableItemOperationPredicate) Matches(input ProtectableItem) 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/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/version.go new file mode 100644 index 00000000000..e99141c9257 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectableitems/version.go @@ -0,0 +1,10 @@ +package replicationprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationprotectableitems/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/README.md new file mode 100644 index 00000000000..159d0ff6ac5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/README.md @@ -0,0 +1,373 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems` Documentation + +The `replicationprotecteditems` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems" +``` + + +### Client Initialization + +```go +client := replicationprotecteditems.NewReplicationProtectedItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectedItemsClient.AddDisks` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.AddDisksInput{ + // ... +} + + +if err := client.AddDisksThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.ApplyRecoveryPoint` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.ApplyRecoveryPointInput{ + // ... +} + + +if err := client.ApplyRecoveryPointThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Create` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.EnableProtectionInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Delete` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.DisableProtectionInput{ + // ... +} + + +if err := client.DeleteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.FailoverCancel` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +if err := client.FailoverCancelThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.FailoverCommit` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +if err := client.FailoverCommitThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Get` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +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: `ReplicationProtectedItemsClient.List` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, replicationprotecteditems.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationprotecteditems.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.ListByReplicationProtectionContainers` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +// alternatively `client.ListByReplicationProtectionContainers(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectionContainersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.PlannedFailover` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.PlannedFailoverInput{ + // ... +} + + +if err := client.PlannedFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Purge` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +if err := client.PurgeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.RemoveDisks` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.RemoveDisksInput{ + // ... +} + + +if err := client.RemoveDisksThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.RepairReplication` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +if err := client.RepairReplicationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Reprotect` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.ReverseReplicationInput{ + // ... +} + + +if err := client.ReprotectThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.ResolveHealthErrors` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.ResolveHealthInput{ + // ... +} + + +if err := client.ResolveHealthErrorsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.SwitchProvider` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.SwitchProviderInput{ + // ... +} + + +if err := client.SwitchProviderThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.TestFailover` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.TestFailoverInput{ + // ... +} + + +if err := client.TestFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.TestFailoverCleanup` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.TestFailoverCleanupInput{ + // ... +} + + +if err := client.TestFailoverCleanupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.UnplannedFailover` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.UnplannedFailoverInput{ + // ... +} + + +if err := client.UnplannedFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.Update` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.UpdateReplicationProtectedItemInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.UpdateAppliance` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.UpdateApplianceForReplicationProtectedItemInput{ + // ... +} + + +if err := client.UpdateApplianceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectedItemsClient.UpdateMobilityService` + +```go +ctx := context.TODO() +id := replicationprotecteditems.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +payload := replicationprotecteditems.UpdateMobilityServiceRequest{ + // ... +} + + +if err := client.UpdateMobilityServiceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/client.go new file mode 100644 index 00000000000..7b83bc196f5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/client.go @@ -0,0 +1,26 @@ +package replicationprotecteditems + +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 ReplicationProtectedItemsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectedItemsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectedItemsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationprotecteditems", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectedItemsClient: %+v", err) + } + + return &ReplicationProtectedItemsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/constants.go new file mode 100644 index 00000000000..59548c822b3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/constants.go @@ -0,0 +1,1020 @@ +package replicationprotecteditems + +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 AgentUpgradeBlockedReason string + +const ( + AgentUpgradeBlockedReasonAgentNoHeartbeat AgentUpgradeBlockedReason = "AgentNoHeartbeat" + AgentUpgradeBlockedReasonAlreadyOnLatestVersion AgentUpgradeBlockedReason = "AlreadyOnLatestVersion" + AgentUpgradeBlockedReasonDistroIsNotReported AgentUpgradeBlockedReason = "DistroIsNotReported" + AgentUpgradeBlockedReasonDistroNotSupportedForUpgrade AgentUpgradeBlockedReason = "DistroNotSupportedForUpgrade" + AgentUpgradeBlockedReasonIncompatibleApplianceVersion AgentUpgradeBlockedReason = "IncompatibleApplianceVersion" + AgentUpgradeBlockedReasonInvalidAgentVersion AgentUpgradeBlockedReason = "InvalidAgentVersion" + AgentUpgradeBlockedReasonInvalidDriverVersion AgentUpgradeBlockedReason = "InvalidDriverVersion" + AgentUpgradeBlockedReasonMissingUpgradePath AgentUpgradeBlockedReason = "MissingUpgradePath" + AgentUpgradeBlockedReasonNotProtected AgentUpgradeBlockedReason = "NotProtected" + AgentUpgradeBlockedReasonProcessServerNoHeartbeat AgentUpgradeBlockedReason = "ProcessServerNoHeartbeat" + AgentUpgradeBlockedReasonRcmProxyNoHeartbeat AgentUpgradeBlockedReason = "RcmProxyNoHeartbeat" + AgentUpgradeBlockedReasonRebootRequired AgentUpgradeBlockedReason = "RebootRequired" + AgentUpgradeBlockedReasonUnknown AgentUpgradeBlockedReason = "Unknown" + AgentUpgradeBlockedReasonUnsupportedProtectionScenario AgentUpgradeBlockedReason = "UnsupportedProtectionScenario" +) + +func PossibleValuesForAgentUpgradeBlockedReason() []string { + return []string{ + string(AgentUpgradeBlockedReasonAgentNoHeartbeat), + string(AgentUpgradeBlockedReasonAlreadyOnLatestVersion), + string(AgentUpgradeBlockedReasonDistroIsNotReported), + string(AgentUpgradeBlockedReasonDistroNotSupportedForUpgrade), + string(AgentUpgradeBlockedReasonIncompatibleApplianceVersion), + string(AgentUpgradeBlockedReasonInvalidAgentVersion), + string(AgentUpgradeBlockedReasonInvalidDriverVersion), + string(AgentUpgradeBlockedReasonMissingUpgradePath), + string(AgentUpgradeBlockedReasonNotProtected), + string(AgentUpgradeBlockedReasonProcessServerNoHeartbeat), + string(AgentUpgradeBlockedReasonRcmProxyNoHeartbeat), + string(AgentUpgradeBlockedReasonRebootRequired), + string(AgentUpgradeBlockedReasonUnknown), + string(AgentUpgradeBlockedReasonUnsupportedProtectionScenario), + } +} + +func (s *AgentUpgradeBlockedReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentUpgradeBlockedReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentUpgradeBlockedReason(input string) (*AgentUpgradeBlockedReason, error) { + vals := map[string]AgentUpgradeBlockedReason{ + "agentnoheartbeat": AgentUpgradeBlockedReasonAgentNoHeartbeat, + "alreadyonlatestversion": AgentUpgradeBlockedReasonAlreadyOnLatestVersion, + "distroisnotreported": AgentUpgradeBlockedReasonDistroIsNotReported, + "distronotsupportedforupgrade": AgentUpgradeBlockedReasonDistroNotSupportedForUpgrade, + "incompatibleapplianceversion": AgentUpgradeBlockedReasonIncompatibleApplianceVersion, + "invalidagentversion": AgentUpgradeBlockedReasonInvalidAgentVersion, + "invaliddriverversion": AgentUpgradeBlockedReasonInvalidDriverVersion, + "missingupgradepath": AgentUpgradeBlockedReasonMissingUpgradePath, + "notprotected": AgentUpgradeBlockedReasonNotProtected, + "processservernoheartbeat": AgentUpgradeBlockedReasonProcessServerNoHeartbeat, + "rcmproxynoheartbeat": AgentUpgradeBlockedReasonRcmProxyNoHeartbeat, + "rebootrequired": AgentUpgradeBlockedReasonRebootRequired, + "unknown": AgentUpgradeBlockedReasonUnknown, + "unsupportedprotectionscenario": AgentUpgradeBlockedReasonUnsupportedProtectionScenario, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentUpgradeBlockedReason(input) + return &out, nil +} + +type AutoProtectionOfDataDisk string + +const ( + AutoProtectionOfDataDiskDisabled AutoProtectionOfDataDisk = "Disabled" + AutoProtectionOfDataDiskEnabled AutoProtectionOfDataDisk = "Enabled" +) + +func PossibleValuesForAutoProtectionOfDataDisk() []string { + return []string{ + string(AutoProtectionOfDataDiskDisabled), + string(AutoProtectionOfDataDiskEnabled), + } +} + +func (s *AutoProtectionOfDataDisk) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoProtectionOfDataDisk(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoProtectionOfDataDisk(input string) (*AutoProtectionOfDataDisk, error) { + vals := map[string]AutoProtectionOfDataDisk{ + "disabled": AutoProtectionOfDataDiskDisabled, + "enabled": AutoProtectionOfDataDiskEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoProtectionOfDataDisk(input) + return &out, nil +} + +type ChurnOptionSelected string + +const ( + ChurnOptionSelectedHigh ChurnOptionSelected = "High" + ChurnOptionSelectedNormal ChurnOptionSelected = "Normal" +) + +func PossibleValuesForChurnOptionSelected() []string { + return []string{ + string(ChurnOptionSelectedHigh), + string(ChurnOptionSelectedNormal), + } +} + +func (s *ChurnOptionSelected) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseChurnOptionSelected(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseChurnOptionSelected(input string) (*ChurnOptionSelected, error) { + vals := map[string]ChurnOptionSelected{ + "high": ChurnOptionSelectedHigh, + "normal": ChurnOptionSelectedNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ChurnOptionSelected(input) + return &out, nil +} + +type DisableProtectionReason string + +const ( + DisableProtectionReasonMigrationComplete DisableProtectionReason = "MigrationComplete" + DisableProtectionReasonNotSpecified DisableProtectionReason = "NotSpecified" +) + +func PossibleValuesForDisableProtectionReason() []string { + return []string{ + string(DisableProtectionReasonMigrationComplete), + string(DisableProtectionReasonNotSpecified), + } +} + +func (s *DisableProtectionReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDisableProtectionReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDisableProtectionReason(input string) (*DisableProtectionReason, error) { + vals := map[string]DisableProtectionReason{ + "migrationcomplete": DisableProtectionReasonMigrationComplete, + "notspecified": DisableProtectionReasonNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DisableProtectionReason(input) + return &out, nil +} + +type DiskAccountType string + +const ( + DiskAccountTypePremiumLRS DiskAccountType = "Premium_LRS" + DiskAccountTypePremiumVTwoLRS DiskAccountType = "PremiumV2_LRS" + DiskAccountTypePremiumZRS DiskAccountType = "Premium_ZRS" + DiskAccountTypeStandardLRS DiskAccountType = "Standard_LRS" + DiskAccountTypeStandardSSDLRS DiskAccountType = "StandardSSD_LRS" + DiskAccountTypeStandardSSDZRS DiskAccountType = "StandardSSD_ZRS" + DiskAccountTypeUltraSSDLRS DiskAccountType = "UltraSSD_LRS" +) + +func PossibleValuesForDiskAccountType() []string { + return []string{ + string(DiskAccountTypePremiumLRS), + string(DiskAccountTypePremiumVTwoLRS), + string(DiskAccountTypePremiumZRS), + string(DiskAccountTypeStandardLRS), + string(DiskAccountTypeStandardSSDLRS), + string(DiskAccountTypeStandardSSDZRS), + string(DiskAccountTypeUltraSSDLRS), + } +} + +func (s *DiskAccountType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskAccountType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskAccountType(input string) (*DiskAccountType, error) { + vals := map[string]DiskAccountType{ + "premium_lrs": DiskAccountTypePremiumLRS, + "premiumv2_lrs": DiskAccountTypePremiumVTwoLRS, + "premium_zrs": DiskAccountTypePremiumZRS, + "standard_lrs": DiskAccountTypeStandardLRS, + "standardssd_lrs": DiskAccountTypeStandardSSDLRS, + "standardssd_zrs": DiskAccountTypeStandardSSDZRS, + "ultrassd_lrs": DiskAccountTypeUltraSSDLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskAccountType(input) + return &out, nil +} + +type DiskReplicationProgressHealth string + +const ( + DiskReplicationProgressHealthInProgress DiskReplicationProgressHealth = "InProgress" + DiskReplicationProgressHealthNoProgress DiskReplicationProgressHealth = "NoProgress" + DiskReplicationProgressHealthNone DiskReplicationProgressHealth = "None" + DiskReplicationProgressHealthQueued DiskReplicationProgressHealth = "Queued" + DiskReplicationProgressHealthSlowProgress DiskReplicationProgressHealth = "SlowProgress" +) + +func PossibleValuesForDiskReplicationProgressHealth() []string { + return []string{ + string(DiskReplicationProgressHealthInProgress), + string(DiskReplicationProgressHealthNoProgress), + string(DiskReplicationProgressHealthNone), + string(DiskReplicationProgressHealthQueued), + string(DiskReplicationProgressHealthSlowProgress), + } +} + +func (s *DiskReplicationProgressHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskReplicationProgressHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskReplicationProgressHealth(input string) (*DiskReplicationProgressHealth, error) { + vals := map[string]DiskReplicationProgressHealth{ + "inprogress": DiskReplicationProgressHealthInProgress, + "noprogress": DiskReplicationProgressHealthNoProgress, + "none": DiskReplicationProgressHealthNone, + "queued": DiskReplicationProgressHealthQueued, + "slowprogress": DiskReplicationProgressHealthSlowProgress, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskReplicationProgressHealth(input) + return &out, nil +} + +type DiskState string + +const ( + DiskStateInitialReplicationFailed DiskState = "InitialReplicationFailed" + DiskStateInitialReplicationPending DiskState = "InitialReplicationPending" + DiskStateProtected DiskState = "Protected" + DiskStateUnavailable DiskState = "Unavailable" +) + +func PossibleValuesForDiskState() []string { + return []string{ + string(DiskStateInitialReplicationFailed), + string(DiskStateInitialReplicationPending), + string(DiskStateProtected), + string(DiskStateUnavailable), + } +} + +func (s *DiskState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskState(input string) (*DiskState, error) { + vals := map[string]DiskState{ + "initialreplicationfailed": DiskStateInitialReplicationFailed, + "initialreplicationpending": DiskStateInitialReplicationPending, + "protected": DiskStateProtected, + "unavailable": DiskStateUnavailable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskState(input) + return &out, nil +} + +type EthernetAddressType string + +const ( + EthernetAddressTypeDynamic EthernetAddressType = "Dynamic" + EthernetAddressTypeStatic EthernetAddressType = "Static" +) + +func PossibleValuesForEthernetAddressType() []string { + return []string{ + string(EthernetAddressTypeDynamic), + string(EthernetAddressTypeStatic), + } +} + +func (s *EthernetAddressType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEthernetAddressType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEthernetAddressType(input string) (*EthernetAddressType, error) { + vals := map[string]EthernetAddressType{ + "dynamic": EthernetAddressTypeDynamic, + "static": EthernetAddressTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EthernetAddressType(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type InMageRcmFailbackRecoveryPointType string + +const ( + InMageRcmFailbackRecoveryPointTypeApplicationConsistent InMageRcmFailbackRecoveryPointType = "ApplicationConsistent" + InMageRcmFailbackRecoveryPointTypeCrashConsistent InMageRcmFailbackRecoveryPointType = "CrashConsistent" +) + +func PossibleValuesForInMageRcmFailbackRecoveryPointType() []string { + return []string{ + string(InMageRcmFailbackRecoveryPointTypeApplicationConsistent), + string(InMageRcmFailbackRecoveryPointTypeCrashConsistent), + } +} + +func (s *InMageRcmFailbackRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInMageRcmFailbackRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInMageRcmFailbackRecoveryPointType(input string) (*InMageRcmFailbackRecoveryPointType, error) { + vals := map[string]InMageRcmFailbackRecoveryPointType{ + "applicationconsistent": InMageRcmFailbackRecoveryPointTypeApplicationConsistent, + "crashconsistent": InMageRcmFailbackRecoveryPointTypeCrashConsistent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InMageRcmFailbackRecoveryPointType(input) + return &out, nil +} + +type LicenseType string + +const ( + LicenseTypeNoLicenseType LicenseType = "NoLicenseType" + LicenseTypeNotSpecified LicenseType = "NotSpecified" + LicenseTypeWindowsServer LicenseType = "WindowsServer" +) + +func PossibleValuesForLicenseType() []string { + return []string{ + string(LicenseTypeNoLicenseType), + string(LicenseTypeNotSpecified), + string(LicenseTypeWindowsServer), + } +} + +func (s *LicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLicenseType(input string) (*LicenseType, error) { + vals := map[string]LicenseType{ + "nolicensetype": LicenseTypeNoLicenseType, + "notspecified": LicenseTypeNotSpecified, + "windowsserver": LicenseTypeWindowsServer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LicenseType(input) + return &out, nil +} + +type LinuxLicenseType string + +const ( + LinuxLicenseTypeLinuxServer LinuxLicenseType = "LinuxServer" + LinuxLicenseTypeNoLicenseType LinuxLicenseType = "NoLicenseType" + LinuxLicenseTypeNotSpecified LinuxLicenseType = "NotSpecified" +) + +func PossibleValuesForLinuxLicenseType() []string { + return []string{ + string(LinuxLicenseTypeLinuxServer), + string(LinuxLicenseTypeNoLicenseType), + string(LinuxLicenseTypeNotSpecified), + } +} + +func (s *LinuxLicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLinuxLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLinuxLicenseType(input string) (*LinuxLicenseType, error) { + vals := map[string]LinuxLicenseType{ + "linuxserver": LinuxLicenseTypeLinuxServer, + "nolicensetype": LinuxLicenseTypeNoLicenseType, + "notspecified": LinuxLicenseTypeNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LinuxLicenseType(input) + return &out, nil +} + +type MobilityAgentUpgradeState string + +const ( + MobilityAgentUpgradeStateCommit MobilityAgentUpgradeState = "Commit" + MobilityAgentUpgradeStateCompleted MobilityAgentUpgradeState = "Completed" + MobilityAgentUpgradeStateNone MobilityAgentUpgradeState = "None" + MobilityAgentUpgradeStateStarted MobilityAgentUpgradeState = "Started" +) + +func PossibleValuesForMobilityAgentUpgradeState() []string { + return []string{ + string(MobilityAgentUpgradeStateCommit), + string(MobilityAgentUpgradeStateCompleted), + string(MobilityAgentUpgradeStateNone), + string(MobilityAgentUpgradeStateStarted), + } +} + +func (s *MobilityAgentUpgradeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMobilityAgentUpgradeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMobilityAgentUpgradeState(input string) (*MobilityAgentUpgradeState, error) { + vals := map[string]MobilityAgentUpgradeState{ + "commit": MobilityAgentUpgradeStateCommit, + "completed": MobilityAgentUpgradeStateCompleted, + "none": MobilityAgentUpgradeStateNone, + "started": MobilityAgentUpgradeStateStarted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MobilityAgentUpgradeState(input) + return &out, nil +} + +type MultiVMGroupCreateOption string + +const ( + MultiVMGroupCreateOptionAutoCreated MultiVMGroupCreateOption = "AutoCreated" + MultiVMGroupCreateOptionUserSpecified MultiVMGroupCreateOption = "UserSpecified" +) + +func PossibleValuesForMultiVMGroupCreateOption() []string { + return []string{ + string(MultiVMGroupCreateOptionAutoCreated), + string(MultiVMGroupCreateOptionUserSpecified), + } +} + +func (s *MultiVMGroupCreateOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMultiVMGroupCreateOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMultiVMGroupCreateOption(input string) (*MultiVMGroupCreateOption, error) { + vals := map[string]MultiVMGroupCreateOption{ + "autocreated": MultiVMGroupCreateOptionAutoCreated, + "userspecified": MultiVMGroupCreateOptionUserSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MultiVMGroupCreateOption(input) + return &out, nil +} + +type PlannedFailoverStatus string + +const ( + PlannedFailoverStatusCancelled PlannedFailoverStatus = "Cancelled" + PlannedFailoverStatusFailed PlannedFailoverStatus = "Failed" + PlannedFailoverStatusSucceeded PlannedFailoverStatus = "Succeeded" + PlannedFailoverStatusUnknown PlannedFailoverStatus = "Unknown" +) + +func PossibleValuesForPlannedFailoverStatus() []string { + return []string{ + string(PlannedFailoverStatusCancelled), + string(PlannedFailoverStatusFailed), + string(PlannedFailoverStatusSucceeded), + string(PlannedFailoverStatusUnknown), + } +} + +func (s *PlannedFailoverStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePlannedFailoverStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePlannedFailoverStatus(input string) (*PlannedFailoverStatus, error) { + vals := map[string]PlannedFailoverStatus{ + "cancelled": PlannedFailoverStatusCancelled, + "failed": PlannedFailoverStatusFailed, + "succeeded": PlannedFailoverStatusSucceeded, + "unknown": PlannedFailoverStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PlannedFailoverStatus(input) + return &out, nil +} + +type RecoveryPointType string + +const ( + RecoveryPointTypeCustom RecoveryPointType = "Custom" + RecoveryPointTypeLatestTag RecoveryPointType = "LatestTag" + RecoveryPointTypeLatestTime RecoveryPointType = "LatestTime" +) + +func PossibleValuesForRecoveryPointType() []string { + return []string{ + string(RecoveryPointTypeCustom), + string(RecoveryPointTypeLatestTag), + string(RecoveryPointTypeLatestTime), + } +} + +func (s *RecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPointType(input string) (*RecoveryPointType, error) { + vals := map[string]RecoveryPointType{ + "custom": RecoveryPointTypeCustom, + "latesttag": RecoveryPointTypeLatestTag, + "latesttime": RecoveryPointTypeLatestTime, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointType(input) + return &out, nil +} + +type ResyncState string + +const ( + ResyncStateNone ResyncState = "None" + ResyncStatePreparedForResynchronization ResyncState = "PreparedForResynchronization" + ResyncStateStartedResynchronization ResyncState = "StartedResynchronization" +) + +func PossibleValuesForResyncState() []string { + return []string{ + string(ResyncStateNone), + string(ResyncStatePreparedForResynchronization), + string(ResyncStateStartedResynchronization), + } +} + +func (s *ResyncState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResyncState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResyncState(input string) (*ResyncState, error) { + vals := map[string]ResyncState{ + "none": ResyncStateNone, + "preparedforresynchronization": ResyncStatePreparedForResynchronization, + "startedresynchronization": ResyncStateStartedResynchronization, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResyncState(input) + return &out, nil +} + +type SecurityConfiguration string + +const ( + SecurityConfigurationDisabled SecurityConfiguration = "Disabled" + SecurityConfigurationEnabled SecurityConfiguration = "Enabled" +) + +func PossibleValuesForSecurityConfiguration() []string { + return []string{ + string(SecurityConfigurationDisabled), + string(SecurityConfigurationEnabled), + } +} + +func (s *SecurityConfiguration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityConfiguration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityConfiguration(input string) (*SecurityConfiguration, error) { + vals := map[string]SecurityConfiguration{ + "disabled": SecurityConfigurationDisabled, + "enabled": SecurityConfigurationEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityConfiguration(input) + return &out, nil +} + +type SecurityType string + +const ( + SecurityTypeConfidentialVM SecurityType = "ConfidentialVM" + SecurityTypeNone SecurityType = "None" + SecurityTypeTrustedLaunch SecurityType = "TrustedLaunch" +) + +func PossibleValuesForSecurityType() []string { + return []string{ + string(SecurityTypeConfidentialVM), + string(SecurityTypeNone), + string(SecurityTypeTrustedLaunch), + } +} + +func (s *SecurityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityType(input string) (*SecurityType, error) { + vals := map[string]SecurityType{ + "confidentialvm": SecurityTypeConfidentialVM, + "none": SecurityTypeNone, + "trustedlaunch": SecurityTypeTrustedLaunch, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityType(input) + return &out, nil +} + +type SqlServerLicenseType string + +const ( + SqlServerLicenseTypeAHUB SqlServerLicenseType = "AHUB" + SqlServerLicenseTypeNoLicenseType SqlServerLicenseType = "NoLicenseType" + SqlServerLicenseTypeNotSpecified SqlServerLicenseType = "NotSpecified" + SqlServerLicenseTypePAYG SqlServerLicenseType = "PAYG" +) + +func PossibleValuesForSqlServerLicenseType() []string { + return []string{ + string(SqlServerLicenseTypeAHUB), + string(SqlServerLicenseTypeNoLicenseType), + string(SqlServerLicenseTypeNotSpecified), + string(SqlServerLicenseTypePAYG), + } +} + +func (s *SqlServerLicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSqlServerLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSqlServerLicenseType(input string) (*SqlServerLicenseType, error) { + vals := map[string]SqlServerLicenseType{ + "ahub": SqlServerLicenseTypeAHUB, + "nolicensetype": SqlServerLicenseTypeNoLicenseType, + "notspecified": SqlServerLicenseTypeNotSpecified, + "payg": SqlServerLicenseTypePAYG, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SqlServerLicenseType(input) + return &out, nil +} + +type VMEncryptionType string + +const ( + VMEncryptionTypeNotEncrypted VMEncryptionType = "NotEncrypted" + VMEncryptionTypeOnePassEncrypted VMEncryptionType = "OnePassEncrypted" + VMEncryptionTypeTwoPassEncrypted VMEncryptionType = "TwoPassEncrypted" +) + +func PossibleValuesForVMEncryptionType() []string { + return []string{ + string(VMEncryptionTypeNotEncrypted), + string(VMEncryptionTypeOnePassEncrypted), + string(VMEncryptionTypeTwoPassEncrypted), + } +} + +func (s *VMEncryptionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMEncryptionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMEncryptionType(input string) (*VMEncryptionType, error) { + vals := map[string]VMEncryptionType{ + "notencrypted": VMEncryptionTypeNotEncrypted, + "onepassencrypted": VMEncryptionTypeOnePassEncrypted, + "twopassencrypted": VMEncryptionTypeTwoPassEncrypted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMEncryptionType(input) + return &out, nil +} + +type VMReplicationProgressHealth string + +const ( + VMReplicationProgressHealthInProgress VMReplicationProgressHealth = "InProgress" + VMReplicationProgressHealthNoProgress VMReplicationProgressHealth = "NoProgress" + VMReplicationProgressHealthNone VMReplicationProgressHealth = "None" + VMReplicationProgressHealthSlowProgress VMReplicationProgressHealth = "SlowProgress" +) + +func PossibleValuesForVMReplicationProgressHealth() []string { + return []string{ + string(VMReplicationProgressHealthInProgress), + string(VMReplicationProgressHealthNoProgress), + string(VMReplicationProgressHealthNone), + string(VMReplicationProgressHealthSlowProgress), + } +} + +func (s *VMReplicationProgressHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMReplicationProgressHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMReplicationProgressHealth(input string) (*VMReplicationProgressHealth, error) { + vals := map[string]VMReplicationProgressHealth{ + "inprogress": VMReplicationProgressHealthInProgress, + "noprogress": VMReplicationProgressHealthNoProgress, + "none": VMReplicationProgressHealthNone, + "slowprogress": VMReplicationProgressHealthSlowProgress, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMReplicationProgressHealth(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_replicationprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_replicationprotecteditem.go new file mode 100644 index 00000000000..ec2c5d221c2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_replicationprotecteditem.go @@ -0,0 +1,157 @@ +package replicationprotecteditems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectedItemId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectedItemId{} + +// ReplicationProtectedItemId is a struct representing the Resource ID for a Replication Protected Item +type ReplicationProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectedItemName string +} + +// NewReplicationProtectedItemID returns a new ReplicationProtectedItemId struct +func NewReplicationProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectedItemName string) ReplicationProtectedItemId { + return ReplicationProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectedItemName: replicationProtectedItemName, + } +} + +// ParseReplicationProtectedItemID parses 'input' into a ReplicationProtectedItemId +func ParseReplicationProtectedItemID(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectedItemIDInsensitively parses 'input' case-insensitively into a ReplicationProtectedItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectedItemIDInsensitively(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectedItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectedItemName, ok = input.Parsed["replicationProtectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectedItemName", input) + } + + return nil +} + +// ValidateReplicationProtectedItemID checks that 'input' can be parsed as a Replication Protected Item ID +func ValidateReplicationProtectedItemID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectedItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protected Item ID +func (id ReplicationProtectedItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectedItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectedItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protected Item ID +func (id ReplicationProtectedItemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectedItems", "replicationProtectedItems", "replicationProtectedItems"), + resourceids.UserSpecifiedSegment("replicationProtectedItemName", "replicationProtectedItemName"), + } +} + +// String returns a human-readable description of this Replication Protected Item ID +func (id ReplicationProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protected Item Name: %q", id.ReplicationProtectedItemName), + } + return fmt.Sprintf("Replication Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_replicationprotecteditem_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_replicationprotecteditem_test.go new file mode 100644 index 00000000000..af1be070147 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_replicationprotecteditem_test.go @@ -0,0 +1,417 @@ +package replicationprotecteditems + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectedItemId{} + +func TestNewReplicationProtectedItemID(t *testing.T) { + id := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectedItemName != "replicationProtectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectedItemName'", id.ReplicationProtectedItemName, "replicationProtectedItemName") + } +} + +func TestFormatReplicationProtectedItemID(t *testing.T) { + actual := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestParseReplicationProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectedItemName: "rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestSegmentsForReplicationProtectedItemId(t *testing.T) { + segments := ReplicationProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectedItemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..90d3e87f91d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_replicationprotectioncontainer.go @@ -0,0 +1,148 @@ +package replicationprotecteditems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectionContainerId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..6a6c47d5d94 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationprotecteditems + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_vault.go new file mode 100644 index 00000000000..35eb0fa0277 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_vault.go @@ -0,0 +1,130 @@ +package replicationprotecteditems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_vault_test.go new file mode 100644 index 00000000000..85390476d93 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationprotecteditems + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_adddisks.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_adddisks.go new file mode 100644 index 00000000000..36621c48786 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_adddisks.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddDisksOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// AddDisks ... +func (c ReplicationProtectedItemsClient) AddDisks(ctx context.Context, id ReplicationProtectedItemId, input AddDisksInput) (result AddDisksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/addDisks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// AddDisksThenPoll performs AddDisks then polls until it's completed +func (c ReplicationProtectedItemsClient) AddDisksThenPoll(ctx context.Context, id ReplicationProtectedItemId, input AddDisksInput) error { + result, err := c.AddDisks(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AddDisks: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AddDisks: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_applyrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_applyrecoverypoint.go new file mode 100644 index 00000000000..01aa0179078 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_applyrecoverypoint.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplyRecoveryPointOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// ApplyRecoveryPoint ... +func (c ReplicationProtectedItemsClient) ApplyRecoveryPoint(ctx context.Context, id ReplicationProtectedItemId, input ApplyRecoveryPointInput) (result ApplyRecoveryPointOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applyRecoveryPoint", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ApplyRecoveryPointThenPoll performs ApplyRecoveryPoint then polls until it's completed +func (c ReplicationProtectedItemsClient) ApplyRecoveryPointThenPoll(ctx context.Context, id ReplicationProtectedItemId, input ApplyRecoveryPointInput) error { + result, err := c.ApplyRecoveryPoint(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApplyRecoveryPoint: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApplyRecoveryPoint: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_create.go new file mode 100644 index 00000000000..0058b44ea0f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_create.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ReplicationProtectedItem +} + +// Create ... +func (c ReplicationProtectedItemsClient) Create(ctx context.Context, id ReplicationProtectedItemId, input EnableProtectionInput) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationProtectedItemsClient) CreateThenPoll(ctx context.Context, id ReplicationProtectedItemId, input EnableProtectionInput) 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/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_delete.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_delete.go new file mode 100644 index 00000000000..6de58173ab5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_delete.go @@ -0,0 +1,74 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 ReplicationProtectedItemsClient) Delete(ctx context.Context, id ReplicationProtectedItemId, input DisableProtectionInput) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.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 ReplicationProtectedItemsClient) DeleteThenPoll(ctx context.Context, id ReplicationProtectedItemId, input DisableProtectionInput) error { + result, err := c.Delete(ctx, id, input) + 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/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_failovercancel.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_failovercancel.go new file mode 100644 index 00000000000..0232cdf2c30 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_failovercancel.go @@ -0,0 +1,71 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverCancelOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// FailoverCancel ... +func (c ReplicationProtectedItemsClient) FailoverCancel(ctx context.Context, id ReplicationProtectedItemId) (result FailoverCancelOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverCancel", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// FailoverCancelThenPoll performs FailoverCancel then polls until it's completed +func (c ReplicationProtectedItemsClient) FailoverCancelThenPoll(ctx context.Context, id ReplicationProtectedItemId) error { + result, err := c.FailoverCancel(ctx, id) + if err != nil { + return fmt.Errorf("performing FailoverCancel: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FailoverCancel: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_failovercommit.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_failovercommit.go new file mode 100644 index 00000000000..be595e3aeda --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_failovercommit.go @@ -0,0 +1,71 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverCommitOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// FailoverCommit ... +func (c ReplicationProtectedItemsClient) FailoverCommit(ctx context.Context, id ReplicationProtectedItemId) (result FailoverCommitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverCommit", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// FailoverCommitThenPoll performs FailoverCommit then polls until it's completed +func (c ReplicationProtectedItemsClient) FailoverCommitThenPoll(ctx context.Context, id ReplicationProtectedItemId) error { + result, err := c.FailoverCommit(ctx, id) + if err != nil { + return fmt.Errorf("performing FailoverCommit: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FailoverCommit: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_get.go new file mode 100644 index 00000000000..5d46e4204f4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_get.go @@ -0,0 +1,53 @@ +package replicationprotecteditems + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ReplicationProtectedItem +} + +// Get ... +func (c ReplicationProtectedItemsClient) Get(ctx context.Context, id ReplicationProtectedItemId) (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 ReplicationProtectedItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_list.go new file mode 100644 index 00000000000..5fe3f745f8f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_list.go @@ -0,0 +1,138 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ReplicationProtectedItem +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationProtectedItem +} + +type ListOperationOptions struct { + Filter *string + SkipToken *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)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + 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 ReplicationProtectedItemsClient) List(ctx context.Context, id VaultId, 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/replicationProtectedItems", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReplicationProtectedItem `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 ReplicationProtectedItemsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ReplicationProtectedItemOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectedItemsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ReplicationProtectedItemOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ReplicationProtectedItem, 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/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_listbyreplicationprotectioncontainers.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_listbyreplicationprotectioncontainers.go new file mode 100644 index 00000000000..c51a013c266 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_listbyreplicationprotectioncontainers.go @@ -0,0 +1,105 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationProtectionContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReplicationProtectedItem +} + +type ListByReplicationProtectionContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationProtectedItem +} + +type ListByReplicationProtectionContainersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectionContainersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectionContainers ... +func (c ReplicationProtectedItemsClient) ListByReplicationProtectionContainers(ctx context.Context, id ReplicationProtectionContainerId) (result ListByReplicationProtectionContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationProtectionContainersCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectedItems", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReplicationProtectedItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionContainersComplete retrieves all the results into a single object +func (c ReplicationProtectedItemsClient) ListByReplicationProtectionContainersComplete(ctx context.Context, id ReplicationProtectionContainerId) (ListByReplicationProtectionContainersCompleteResult, error) { + return c.ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx, id, ReplicationProtectedItemOperationPredicate{}) +} + +// ListByReplicationProtectionContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectedItemsClient) ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionContainerId, predicate ReplicationProtectedItemOperationPredicate) (result ListByReplicationProtectionContainersCompleteResult, err error) { + items := make([]ReplicationProtectedItem, 0) + + resp, err := c.ListByReplicationProtectionContainers(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 = ListByReplicationProtectionContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_plannedfailover.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_plannedfailover.go new file mode 100644 index 00000000000..12c98413547 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_plannedfailover.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlannedFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// PlannedFailover ... +func (c ReplicationProtectedItemsClient) PlannedFailover(ctx context.Context, id ReplicationProtectedItemId, input PlannedFailoverInput) (result PlannedFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/plannedFailover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PlannedFailoverThenPoll performs PlannedFailover then polls until it's completed +func (c ReplicationProtectedItemsClient) PlannedFailoverThenPoll(ctx context.Context, id ReplicationProtectedItemId, input PlannedFailoverInput) error { + result, err := c.PlannedFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PlannedFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PlannedFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_purge.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_purge.go new file mode 100644 index 00000000000..9917dd3997d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_purge.go @@ -0,0 +1,70 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c ReplicationProtectedItemsClient) Purge(ctx context.Context, id ReplicationProtectedItemId) (result PurgeOperationResponse, 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 +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c ReplicationProtectedItemsClient) PurgeThenPoll(ctx context.Context, id ReplicationProtectedItemId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_removedisks.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_removedisks.go new file mode 100644 index 00000000000..13caa5a940e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_removedisks.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoveDisksOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// RemoveDisks ... +func (c ReplicationProtectedItemsClient) RemoveDisks(ctx context.Context, id ReplicationProtectedItemId, input RemoveDisksInput) (result RemoveDisksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/removeDisks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RemoveDisksThenPoll performs RemoveDisks then polls until it's completed +func (c ReplicationProtectedItemsClient) RemoveDisksThenPoll(ctx context.Context, id ReplicationProtectedItemId, input RemoveDisksInput) error { + result, err := c.RemoveDisks(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RemoveDisks: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RemoveDisks: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_repairreplication.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_repairreplication.go new file mode 100644 index 00000000000..f755248eff3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_repairreplication.go @@ -0,0 +1,71 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RepairReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// RepairReplication ... +func (c ReplicationProtectedItemsClient) RepairReplication(ctx context.Context, id ReplicationProtectedItemId) (result RepairReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/repairReplication", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RepairReplicationThenPoll performs RepairReplication then polls until it's completed +func (c ReplicationProtectedItemsClient) RepairReplicationThenPoll(ctx context.Context, id ReplicationProtectedItemId) error { + result, err := c.RepairReplication(ctx, id) + if err != nil { + return fmt.Errorf("performing RepairReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RepairReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_reprotect.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_reprotect.go new file mode 100644 index 00000000000..3da5ec114b7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_reprotect.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReprotectOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// Reprotect ... +func (c ReplicationProtectedItemsClient) Reprotect(ctx context.Context, id ReplicationProtectedItemId, input ReverseReplicationInput) (result ReprotectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reProtect", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReprotectThenPoll performs Reprotect then polls until it's completed +func (c ReplicationProtectedItemsClient) ReprotectThenPoll(ctx context.Context, id ReplicationProtectedItemId, input ReverseReplicationInput) error { + result, err := c.Reprotect(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Reprotect: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reprotect: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_resolvehealtherrors.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_resolvehealtherrors.go new file mode 100644 index 00000000000..8d61f1ff79d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_resolvehealtherrors.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResolveHealthErrorsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// ResolveHealthErrors ... +func (c ReplicationProtectedItemsClient) ResolveHealthErrors(ctx context.Context, id ReplicationProtectedItemId, input ResolveHealthInput) (result ResolveHealthErrorsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resolveHealthErrors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResolveHealthErrorsThenPoll performs ResolveHealthErrors then polls until it's completed +func (c ReplicationProtectedItemsClient) ResolveHealthErrorsThenPoll(ctx context.Context, id ReplicationProtectedItemId, input ResolveHealthInput) error { + result, err := c.ResolveHealthErrors(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ResolveHealthErrors: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResolveHealthErrors: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_switchprovider.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_switchprovider.go new file mode 100644 index 00000000000..b49df7171d5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_switchprovider.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchProviderOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// SwitchProvider ... +func (c ReplicationProtectedItemsClient) SwitchProvider(ctx context.Context, id ReplicationProtectedItemId, input SwitchProviderInput) (result SwitchProviderOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/switchProvider", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SwitchProviderThenPoll performs SwitchProvider then polls until it's completed +func (c ReplicationProtectedItemsClient) SwitchProviderThenPoll(ctx context.Context, id ReplicationProtectedItemId, input SwitchProviderInput) error { + result, err := c.SwitchProvider(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwitchProvider: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwitchProvider: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_testfailover.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_testfailover.go new file mode 100644 index 00000000000..b9e2751e6ab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_testfailover.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// TestFailover ... +func (c ReplicationProtectedItemsClient) TestFailover(ctx context.Context, id ReplicationProtectedItemId, input TestFailoverInput) (result TestFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// TestFailoverThenPoll performs TestFailover then polls until it's completed +func (c ReplicationProtectedItemsClient) TestFailoverThenPoll(ctx context.Context, id ReplicationProtectedItemId, input TestFailoverInput) error { + result, err := c.TestFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_testfailovercleanup.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_testfailovercleanup.go new file mode 100644 index 00000000000..70adce69ef2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_testfailovercleanup.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverCleanupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// TestFailoverCleanup ... +func (c ReplicationProtectedItemsClient) TestFailoverCleanup(ctx context.Context, id ReplicationProtectedItemId, input TestFailoverCleanupInput) (result TestFailoverCleanupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailoverCleanup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// TestFailoverCleanupThenPoll performs TestFailoverCleanup then polls until it's completed +func (c ReplicationProtectedItemsClient) TestFailoverCleanupThenPoll(ctx context.Context, id ReplicationProtectedItemId, input TestFailoverCleanupInput) error { + result, err := c.TestFailoverCleanup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailoverCleanup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailoverCleanup: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_unplannedfailover.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_unplannedfailover.go new file mode 100644 index 00000000000..dce055d914d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_unplannedfailover.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnplannedFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// UnplannedFailover ... +func (c ReplicationProtectedItemsClient) UnplannedFailover(ctx context.Context, id ReplicationProtectedItemId, input UnplannedFailoverInput) (result UnplannedFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/unplannedFailover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UnplannedFailoverThenPoll performs UnplannedFailover then polls until it's completed +func (c ReplicationProtectedItemsClient) UnplannedFailoverThenPoll(ctx context.Context, id ReplicationProtectedItemId, input UnplannedFailoverInput) error { + result, err := c.UnplannedFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UnplannedFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UnplannedFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_update.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_update.go new file mode 100644 index 00000000000..2c21514383f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_update.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ReplicationProtectedItem +} + +// Update ... +func (c ReplicationProtectedItemsClient) Update(ctx context.Context, id ReplicationProtectedItemId, input UpdateReplicationProtectedItemInput) (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 ReplicationProtectedItemsClient) UpdateThenPoll(ctx context.Context, id ReplicationProtectedItemId, input UpdateReplicationProtectedItemInput) 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/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_updateappliance.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_updateappliance.go new file mode 100644 index 00000000000..e4dbc3fbd83 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_updateappliance.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateApplianceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// UpdateAppliance ... +func (c ReplicationProtectedItemsClient) UpdateAppliance(ctx context.Context, id ReplicationProtectedItemId, input UpdateApplianceForReplicationProtectedItemInput) (result UpdateApplianceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updateAppliance", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateApplianceThenPoll performs UpdateAppliance then polls until it's completed +func (c ReplicationProtectedItemsClient) UpdateApplianceThenPoll(ctx context.Context, id ReplicationProtectedItemId, input UpdateApplianceForReplicationProtectedItemInput) error { + result, err := c.UpdateAppliance(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateAppliance: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateAppliance: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_updatemobilityservice.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_updatemobilityservice.go new file mode 100644 index 00000000000..36e2bbdfc24 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/method_updatemobilityservice.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMobilityServiceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectedItem +} + +// UpdateMobilityService ... +func (c ReplicationProtectedItemsClient) UpdateMobilityService(ctx context.Context, id ReplicationProtectedItemId, input UpdateMobilityServiceRequest) (result UpdateMobilityServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updateMobilityService", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateMobilityServiceThenPoll performs UpdateMobilityService then polls until it's completed +func (c ReplicationProtectedItemsClient) UpdateMobilityServiceThenPoll(ctx context.Context, id ReplicationProtectedItemId, input UpdateMobilityServiceRequest) error { + result, err := c.UpdateMobilityService(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateMobilityService: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateMobilityService: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aadddisksinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aadddisksinput.go new file mode 100644 index 00000000000..fee67d43e65 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aadddisksinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +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 _ AddDisksProviderSpecificInput = A2AAddDisksInput{} + +type A2AAddDisksInput struct { + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AVMManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from AddDisksProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AAddDisksInput) AddDisksProviderSpecificInput() BaseAddDisksProviderSpecificInputImpl { + return BaseAddDisksProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AAddDisksInput{} + +func (s A2AAddDisksInput) MarshalJSON() ([]byte, error) { + type wrapper A2AAddDisksInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AAddDisksInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AAddDisksInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AAddDisksInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aapplyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aapplyrecoverypointinput.go new file mode 100644 index 00000000000..b119a4a2cb1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aapplyrecoverypointinput.go @@ -0,0 +1,49 @@ +package replicationprotecteditems + +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 _ ApplyRecoveryPointProviderSpecificInput = A2AApplyRecoveryPointInput{} + +type A2AApplyRecoveryPointInput struct { + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AApplyRecoveryPointInput) ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl { + return BaseApplyRecoveryPointProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AApplyRecoveryPointInput{} + +func (s A2AApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper A2AApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AApplyRecoveryPointInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2acrossclustermigrationapplyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2acrossclustermigrationapplyrecoverypointinput.go new file mode 100644 index 00000000000..208b0ec18ba --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2acrossclustermigrationapplyrecoverypointinput.go @@ -0,0 +1,49 @@ +package replicationprotecteditems + +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 _ ApplyRecoveryPointProviderSpecificInput = A2ACrossClusterMigrationApplyRecoveryPointInput{} + +type A2ACrossClusterMigrationApplyRecoveryPointInput struct { + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ACrossClusterMigrationApplyRecoveryPointInput) ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl { + return BaseApplyRecoveryPointProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ACrossClusterMigrationApplyRecoveryPointInput{} + +func (s A2ACrossClusterMigrationApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationApplyRecoveryPointInput: %+v", err) + } + + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2acrossclustermigrationenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2acrossclustermigrationenableprotectioninput.go new file mode 100644 index 00000000000..ee057b3e0c5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2acrossclustermigrationenableprotectioninput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +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 _ EnableProtectionProviderSpecificInput = A2ACrossClusterMigrationEnableProtectionInput{} + +type A2ACrossClusterMigrationEnableProtectionInput struct { + FabricObjectId *string `json:"fabricObjectId,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ACrossClusterMigrationEnableProtectionInput) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return BaseEnableProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ACrossClusterMigrationEnableProtectionInput{} + +func (s A2ACrossClusterMigrationEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationEnableProtectionInput: %+v", err) + } + + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2acrossclustermigrationreplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2acrossclustermigrationreplicationdetails.go new file mode 100644 index 00000000000..afc9553bcd0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2acrossclustermigrationreplicationdetails.go @@ -0,0 +1,55 @@ +package replicationprotecteditems + +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 _ ReplicationProviderSpecificSettings = A2ACrossClusterMigrationReplicationDetails{} + +type A2ACrossClusterMigrationReplicationDetails struct { + FabricObjectId *string `json:"fabricObjectId,omitempty"` + LifecycleId *string `json:"lifecycleId,omitempty"` + OsType *string `json:"osType,omitempty"` + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s A2ACrossClusterMigrationReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ACrossClusterMigrationReplicationDetails{} + +func (s A2ACrossClusterMigrationReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aenableprotectioninput.go new file mode 100644 index 00000000000..90a041ca1b2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aenableprotectioninput.go @@ -0,0 +1,71 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EnableProtectionProviderSpecificInput = A2AEnableProtectionInput{} + +type A2AEnableProtectionInput struct { + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + FabricObjectId string `json:"fabricObjectId"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + ProtectionClusterId *string `json:"protectionClusterId,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryAzureNetworkId *string `json:"recoveryAzureNetworkId,omitempty"` + RecoveryBootDiagStorageAccountId *string `json:"recoveryBootDiagStorageAccountId,omitempty"` + RecoveryCapacityReservationGroupId *string `json:"recoveryCapacityReservationGroupId,omitempty"` + RecoveryCloudServiceId *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoverySubnetName *string `json:"recoverySubnetName,omitempty"` + RecoveryVirtualMachineScaleSetId *string `json:"recoveryVirtualMachineScaleSetId,omitempty"` + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AVMManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AEnableProtectionInput) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return BaseEnableProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AEnableProtectionInput{} + +func (s A2AEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper A2AEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AEnableProtectionInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aprotecteddiskdetails.go new file mode 100644 index 00000000000..1f03409b8f6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aprotecteddiskdetails.go @@ -0,0 +1,30 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AProtectedDiskDetails struct { + AllowedDiskLevelOperation *[]string `json:"allowedDiskLevelOperation,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` + DataPendingInStagingStorageAccountInMB *float64 `json:"dataPendingInStagingStorageAccountInMB,omitempty"` + DekKeyVaultArmId *string `json:"dekKeyVaultArmId,omitempty"` + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskState *string `json:"diskState,omitempty"` + DiskType *string `json:"diskType,omitempty"` + DiskUri *string `json:"diskUri,omitempty"` + FailoverDiskName *string `json:"failoverDiskName,omitempty"` + IsDiskEncrypted *bool `json:"isDiskEncrypted,omitempty"` + IsDiskKeyEncrypted *bool `json:"isDiskKeyEncrypted,omitempty"` + KekKeyVaultArmId *string `json:"kekKeyVaultArmId,omitempty"` + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + MonitoringPercentageCompletion *int64 `json:"monitoringPercentageCompletion,omitempty"` + PrimaryDiskAzureStorageAccountId *string `json:"primaryDiskAzureStorageAccountId,omitempty"` + PrimaryStagingAzureStorageAccountId *string `json:"primaryStagingAzureStorageAccountId,omitempty"` + RecoveryAzureStorageAccountId *string `json:"recoveryAzureStorageAccountId,omitempty"` + RecoveryDiskUri *string `json:"recoveryDiskUri,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` + TfoDiskName *string `json:"tfoDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aprotectedmanageddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aprotectedmanageddiskdetails.go new file mode 100644 index 00000000000..f531b7431ce --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aprotectedmanageddiskdetails.go @@ -0,0 +1,35 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AProtectedManagedDiskDetails struct { + AllowedDiskLevelOperation *[]string `json:"allowedDiskLevelOperation,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` + DataPendingInStagingStorageAccountInMB *float64 `json:"dataPendingInStagingStorageAccountInMB,omitempty"` + DekKeyVaultArmId *string `json:"dekKeyVaultArmId,omitempty"` + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskState *string `json:"diskState,omitempty"` + DiskType *string `json:"diskType,omitempty"` + FailoverDiskName *string `json:"failoverDiskName,omitempty"` + IsDiskEncrypted *bool `json:"isDiskEncrypted,omitempty"` + IsDiskKeyEncrypted *bool `json:"isDiskKeyEncrypted,omitempty"` + KekKeyVaultArmId *string `json:"kekKeyVaultArmId,omitempty"` + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + MonitoringPercentageCompletion *int64 `json:"monitoringPercentageCompletion,omitempty"` + PrimaryDiskEncryptionSetId *string `json:"primaryDiskEncryptionSetId,omitempty"` + PrimaryStagingAzureStorageAccountId *string `json:"primaryStagingAzureStorageAccountId,omitempty"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryOrignalTargetDiskId *string `json:"recoveryOrignalTargetDiskId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryReplicaDiskId *string `json:"recoveryReplicaDiskId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` + RecoveryTargetDiskId *string `json:"recoveryTargetDiskId,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` + TfoDiskName *string `json:"tfoDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aremovedisksinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aremovedisksinput.go new file mode 100644 index 00000000000..b5f9961fdfc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aremovedisksinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +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 _ RemoveDisksProviderSpecificInput = A2ARemoveDisksInput{} + +type A2ARemoveDisksInput struct { + VMDisksUris *[]string `json:"vmDisksUris,omitempty"` + VMManagedDisksIds *[]string `json:"vmManagedDisksIds,omitempty"` + + // Fields inherited from RemoveDisksProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ARemoveDisksInput) RemoveDisksProviderSpecificInput() BaseRemoveDisksProviderSpecificInputImpl { + return BaseRemoveDisksProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ARemoveDisksInput{} + +func (s A2ARemoveDisksInput) MarshalJSON() ([]byte, error) { + type wrapper A2ARemoveDisksInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ARemoveDisksInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ARemoveDisksInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ARemoveDisksInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2areplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2areplicationdetails.go new file mode 100644 index 00000000000..11126570f85 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2areplicationdetails.go @@ -0,0 +1,107 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationProviderSpecificSettings = A2AReplicationDetails{} + +type A2AReplicationDetails struct { + AgentCertificateExpiryDate *string `json:"agentCertificateExpiryDate,omitempty"` + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + ChurnOptionSelected *ChurnOptionSelected `json:"churnOptionSelected,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + InitialPrimaryExtendedLocation *edgezones.Model `json:"initialPrimaryExtendedLocation,omitempty"` + InitialPrimaryFabricLocation *string `json:"initialPrimaryFabricLocation,omitempty"` + InitialPrimaryZone *string `json:"initialPrimaryZone,omitempty"` + InitialRecoveryExtendedLocation *edgezones.Model `json:"initialRecoveryExtendedLocation,omitempty"` + InitialRecoveryFabricLocation *string `json:"initialRecoveryFabricLocation,omitempty"` + InitialRecoveryZone *string `json:"initialRecoveryZone,omitempty"` + IsClusterInfraReady *bool `json:"isClusterInfraReady,omitempty"` + IsReplicationAgentCertificateUpdateRequired *bool `json:"isReplicationAgentCertificateUpdateRequired,omitempty"` + IsReplicationAgentUpdateRequired *bool `json:"isReplicationAgentUpdateRequired,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LifecycleId *string `json:"lifecycleId,omitempty"` + ManagementId *string `json:"managementId,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + MonitoringPercentageCompletion *int64 `json:"monitoringPercentageCompletion,omitempty"` + MultiVMGroupCreateOption *MultiVMGroupCreateOption `json:"multiVmGroupCreateOption,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + OsType *string `json:"osType,omitempty"` + PrimaryAvailabilityZone *string `json:"primaryAvailabilityZone,omitempty"` + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + ProtectedDisks *[]A2AProtectedDiskDetails `json:"protectedDisks,omitempty"` + ProtectedManagedDisks *[]A2AProtectedManagedDiskDetails `json:"protectedManagedDisks,omitempty"` + ProtectionClusterId *string `json:"protectionClusterId,omitempty"` + RecoveryAvailabilitySet *string `json:"recoveryAvailabilitySet,omitempty"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryAzureGeneration *string `json:"recoveryAzureGeneration,omitempty"` + RecoveryAzureResourceGroupId *string `json:"recoveryAzureResourceGroupId,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + RecoveryBootDiagStorageAccountId *string `json:"recoveryBootDiagStorageAccountId,omitempty"` + RecoveryCapacityReservationGroupId *string `json:"recoveryCapacityReservationGroupId,omitempty"` + RecoveryCloudService *string `json:"recoveryCloudService,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` + RecoveryFabricObjectId *string `json:"recoveryFabricObjectId,omitempty"` + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + RecoveryVirtualMachineScaleSetId *string `json:"recoveryVirtualMachineScaleSetId,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SelectedRecoveryAzureNetworkId *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + SelectedTfoAzureNetworkId *string `json:"selectedTfoAzureNetworkId,omitempty"` + TestFailoverRecoveryFabricObjectId *string `json:"testFailoverRecoveryFabricObjectId,omitempty"` + TfoAzureVMName *string `json:"tfoAzureVMName,omitempty"` + UnprotectedDisks *[]A2AUnprotectedDiskDetails `json:"unprotectedDisks,omitempty"` + VMEncryptionType *VMEncryptionType `json:"vmEncryptionType,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + VMSyncedConfigDetails *AzureToAzureVMSyncedConfigDetails `json:"vmSyncedConfigDetails,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s A2AReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AReplicationDetails{} + +func (s A2AReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2areprotectinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2areprotectinput.go new file mode 100644 index 00000000000..a4d37006651 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2areprotectinput.go @@ -0,0 +1,55 @@ +package replicationprotecteditems + +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 _ ReverseReplicationProviderSpecificInput = A2AReprotectInput{} + +type A2AReprotectInput struct { + PolicyId *string `json:"policyId,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryCloudServiceId *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AReprotectInput) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return BaseReverseReplicationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AReprotectInput{} + +func (s A2AReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper A2AReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AReprotectInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2atestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2atestfailoverinput.go new file mode 100644 index 00000000000..40bfb26f8a7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2atestfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +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 _ TestFailoverProviderSpecificInput = A2ATestFailoverInput{} + +type A2ATestFailoverInput struct { + CloudServiceCreationOption *string `json:"cloudServiceCreationOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ATestFailoverInput) TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl { + return BaseTestFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ATestFailoverInput{} + +func (s A2ATestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper A2ATestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ATestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ATestFailoverInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ATestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aunplannedfailoverinput.go new file mode 100644 index 00000000000..2248e7c8354 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aunplannedfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +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 _ UnplannedFailoverProviderSpecificInput = A2AUnplannedFailoverInput{} + +type A2AUnplannedFailoverInput struct { + CloudServiceCreationOption *string `json:"cloudServiceCreationOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AUnplannedFailoverInput) UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl { + return BaseUnplannedFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AUnplannedFailoverInput{} + +func (s A2AUnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper A2AUnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AUnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AUnplannedFailoverInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AUnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aunprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aunprotecteddiskdetails.go new file mode 100644 index 00000000000..e0a224a5724 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aunprotecteddiskdetails.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AUnprotectedDiskDetails struct { + DiskAutoProtectionStatus *AutoProtectionOfDataDisk `json:"diskAutoProtectionStatus,omitempty"` + DiskLunId *int64 `json:"diskLunId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aupdatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aupdatereplicationprotectediteminput.go new file mode 100644 index 00000000000..aae1b7f832e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2aupdatereplicationprotectediteminput.go @@ -0,0 +1,58 @@ +package replicationprotecteditems + +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 _ UpdateReplicationProtectedItemProviderInput = A2AUpdateReplicationProtectedItemInput{} + +type A2AUpdateReplicationProtectedItemInput struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + ManagedDiskUpdateDetails *[]A2AVMManagedDiskUpdateDetails `json:"managedDiskUpdateDetails,omitempty"` + RecoveryBootDiagStorageAccountId *string `json:"recoveryBootDiagStorageAccountId,omitempty"` + RecoveryCapacityReservationGroupId *string `json:"recoveryCapacityReservationGroupId,omitempty"` + RecoveryCloudServiceId *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryVirtualMachineScaleSetId *string `json:"recoveryVirtualMachineScaleSetId,omitempty"` + TfoAzureVMName *string `json:"tfoAzureVMName,omitempty"` + + // Fields inherited from UpdateReplicationProtectedItemProviderInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AUpdateReplicationProtectedItemInput) UpdateReplicationProtectedItemProviderInput() BaseUpdateReplicationProtectedItemProviderInputImpl { + return BaseUpdateReplicationProtectedItemProviderInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AUpdateReplicationProtectedItemInput{} + +func (s A2AUpdateReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper A2AUpdateReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AUpdateReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AUpdateReplicationProtectedItemInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AUpdateReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2avmdiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2avmdiskinputdetails.go new file mode 100644 index 00000000000..c7aef1ff04a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2avmdiskinputdetails.go @@ -0,0 +1,10 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMDiskInputDetails struct { + DiskUri string `json:"diskUri"` + PrimaryStagingAzureStorageAccountId string `json:"primaryStagingAzureStorageAccountId"` + RecoveryAzureStorageAccountId string `json:"recoveryAzureStorageAccountId"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2avmmanageddiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2avmmanageddiskinputdetails.go new file mode 100644 index 00000000000..d233d499b30 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2avmmanageddiskinputdetails.go @@ -0,0 +1,14 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMManagedDiskInputDetails struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + DiskId string `json:"diskId"` + PrimaryStagingAzureStorageAccountId string `json:"primaryStagingAzureStorageAccountId"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryResourceGroupId string `json:"recoveryResourceGroupId"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2avmmanageddiskupdatedetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2avmmanageddiskupdatedetails.go new file mode 100644 index 00000000000..a021eaff3de --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_a2avmmanageddiskupdatedetails.go @@ -0,0 +1,13 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMManagedDiskUpdateDetails struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + DiskId *string `json:"diskId,omitempty"` + FailoverDiskName *string `json:"failoverDiskName,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` + TfoDiskName *string `json:"tfoDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_adddisksinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_adddisksinput.go new file mode 100644 index 00000000000..fb324e0c8f7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_adddisksinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddDisksInput struct { + Properties *AddDisksInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_adddisksinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_adddisksinputproperties.go new file mode 100644 index 00000000000..b1f6c4bf18d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_adddisksinputproperties.go @@ -0,0 +1,33 @@ +package replicationprotecteditems + +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 AddDisksInputProperties struct { + ProviderSpecificDetails AddDisksProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &AddDisksInputProperties{} + +func (s *AddDisksInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AddDisksInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalAddDisksProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'AddDisksInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_adddisksproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_adddisksproviderspecificinput.go new file mode 100644 index 00000000000..c9d2aacc5fc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_adddisksproviderspecificinput.go @@ -0,0 +1,83 @@ +package replicationprotecteditems + +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 AddDisksProviderSpecificInput interface { + AddDisksProviderSpecificInput() BaseAddDisksProviderSpecificInputImpl +} + +var _ AddDisksProviderSpecificInput = BaseAddDisksProviderSpecificInputImpl{} + +type BaseAddDisksProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseAddDisksProviderSpecificInputImpl) AddDisksProviderSpecificInput() BaseAddDisksProviderSpecificInputImpl { + return s +} + +var _ AddDisksProviderSpecificInput = RawAddDisksProviderSpecificInputImpl{} + +// RawAddDisksProviderSpecificInputImpl 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 RawAddDisksProviderSpecificInputImpl struct { + addDisksProviderSpecificInput BaseAddDisksProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawAddDisksProviderSpecificInputImpl) AddDisksProviderSpecificInput() BaseAddDisksProviderSpecificInputImpl { + return s.addDisksProviderSpecificInput +} + +func UnmarshalAddDisksProviderSpecificInputImplementation(input []byte) (AddDisksProviderSpecificInput, 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 AddDisksProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AAddDisksInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AAddDisksInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmAddDisksInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmAddDisksInput: %+v", err) + } + return out, nil + } + + var parent BaseAddDisksProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseAddDisksProviderSpecificInputImpl: %+v", err) + } + + return RawAddDisksProviderSpecificInputImpl{ + addDisksProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_applyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_applyrecoverypointinput.go new file mode 100644 index 00000000000..6ae39e3cd2f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_applyrecoverypointinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplyRecoveryPointInput struct { + Properties ApplyRecoveryPointInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_applyrecoverypointinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_applyrecoverypointinputproperties.go new file mode 100644 index 00000000000..dddab909551 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_applyrecoverypointinputproperties.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +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 ApplyRecoveryPointInputProperties struct { + ProviderSpecificDetails ApplyRecoveryPointProviderSpecificInput `json:"providerSpecificDetails"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` +} + +var _ json.Unmarshaler = &ApplyRecoveryPointInputProperties{} + +func (s *ApplyRecoveryPointInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.RecoveryPointId = decoded.RecoveryPointId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ApplyRecoveryPointInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalApplyRecoveryPointProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ApplyRecoveryPointInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_applyrecoverypointproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_applyrecoverypointproviderspecificinput.go new file mode 100644 index 00000000000..cc3ce3c881f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_applyrecoverypointproviderspecificinput.go @@ -0,0 +1,107 @@ +package replicationprotecteditems + +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 ApplyRecoveryPointProviderSpecificInput interface { + ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl +} + +var _ ApplyRecoveryPointProviderSpecificInput = BaseApplyRecoveryPointProviderSpecificInputImpl{} + +type BaseApplyRecoveryPointProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseApplyRecoveryPointProviderSpecificInputImpl) ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl { + return s +} + +var _ ApplyRecoveryPointProviderSpecificInput = RawApplyRecoveryPointProviderSpecificInputImpl{} + +// RawApplyRecoveryPointProviderSpecificInputImpl 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 RawApplyRecoveryPointProviderSpecificInputImpl struct { + applyRecoveryPointProviderSpecificInput BaseApplyRecoveryPointProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawApplyRecoveryPointProviderSpecificInputImpl) ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl { + return s.applyRecoveryPointProviderSpecificInput +} + +func UnmarshalApplyRecoveryPointProviderSpecificInputImplementation(input []byte) (ApplyRecoveryPointProviderSpecificInput, 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 ApplyRecoveryPointProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2ApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2ApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmApplyRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmApplyRecoveryPointInput: %+v", err) + } + return out, nil + } + + var parent BaseApplyRecoveryPointProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseApplyRecoveryPointProviderSpecificInputImpl: %+v", err) + } + + return RawApplyRecoveryPointProviderSpecificInputImpl{ + applyRecoveryPointProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_azuretoazurevmsyncedconfigdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_azuretoazurevmsyncedconfigdetails.go new file mode 100644 index 00000000000..7632016e150 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_azuretoazurevmsyncedconfigdetails.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureToAzureVMSyncedConfigDetails struct { + InputEndpoints *[]InputEndpoint `json:"inputEndpoints,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_azurevmdiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_azurevmdiskdetails.go new file mode 100644 index 00000000000..d2778fb03f3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_azurevmdiskdetails.go @@ -0,0 +1,17 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureVMDiskDetails struct { + CustomTargetDiskName *string `json:"customTargetDiskName,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + LunId *string `json:"lunId,omitempty"` + MaxSizeMB *string `json:"maxSizeMB,omitempty"` + TargetDiskLocation *string `json:"targetDiskLocation,omitempty"` + TargetDiskName *string `json:"targetDiskName,omitempty"` + VhdId *string `json:"vhdId,omitempty"` + VhdName *string `json:"vhdName,omitempty"` + VhdType *string `json:"vhdType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_currentscenariodetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_currentscenariodetails.go new file mode 100644 index 00000000000..af5783a8a50 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_currentscenariodetails.go @@ -0,0 +1,28 @@ +package replicationprotecteditems + +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 CurrentScenarioDetails struct { + JobId *string `json:"jobId,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *CurrentScenarioDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CurrentScenarioDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_disableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_disableprotectioninput.go new file mode 100644 index 00000000000..c09eed86ccb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_disableprotectioninput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisableProtectionInput struct { + Properties DisableProtectionInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_disableprotectioninputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_disableprotectioninputproperties.go new file mode 100644 index 00000000000..d451a95c96c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_disableprotectioninputproperties.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +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 DisableProtectionInputProperties struct { + DisableProtectionReason *DisableProtectionReason `json:"disableProtectionReason,omitempty"` + ReplicationProviderInput DisableProtectionProviderSpecificInput `json:"replicationProviderInput"` +} + +var _ json.Unmarshaler = &DisableProtectionInputProperties{} + +func (s *DisableProtectionInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DisableProtectionReason *DisableProtectionReason `json:"disableProtectionReason,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DisableProtectionReason = decoded.DisableProtectionReason + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DisableProtectionInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["replicationProviderInput"]; ok { + impl, err := UnmarshalDisableProtectionProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ReplicationProviderInput' for 'DisableProtectionInputProperties': %+v", err) + } + s.ReplicationProviderInput = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_disableprotectionproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_disableprotectionproviderspecificinput.go new file mode 100644 index 00000000000..ce187d71b83 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_disableprotectionproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 DisableProtectionProviderSpecificInput interface { + DisableProtectionProviderSpecificInput() BaseDisableProtectionProviderSpecificInputImpl +} + +var _ DisableProtectionProviderSpecificInput = BaseDisableProtectionProviderSpecificInputImpl{} + +type BaseDisableProtectionProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseDisableProtectionProviderSpecificInputImpl) DisableProtectionProviderSpecificInput() BaseDisableProtectionProviderSpecificInputImpl { + return s +} + +var _ DisableProtectionProviderSpecificInput = RawDisableProtectionProviderSpecificInputImpl{} + +// RawDisableProtectionProviderSpecificInputImpl 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 RawDisableProtectionProviderSpecificInputImpl struct { + disableProtectionProviderSpecificInput BaseDisableProtectionProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawDisableProtectionProviderSpecificInputImpl) DisableProtectionProviderSpecificInput() BaseDisableProtectionProviderSpecificInputImpl { + return s.disableProtectionProviderSpecificInput +} + +func UnmarshalDisableProtectionProviderSpecificInputImplementation(input []byte) (DisableProtectionProviderSpecificInput, 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 DisableProtectionProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "InMage") { + var out InMageDisableProtectionProviderSpecificInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageDisableProtectionProviderSpecificInput: %+v", err) + } + return out, nil + } + + var parent BaseDisableProtectionProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDisableProtectionProviderSpecificInputImpl: %+v", err) + } + + return RawDisableProtectionProviderSpecificInputImpl{ + disableProtectionProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_diskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_diskdetails.go new file mode 100644 index 00000000000..f64e47bcb4c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_diskdetails.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// 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 { + MaxSizeMB *int64 `json:"maxSizeMB,omitempty"` + VhdId *string `json:"vhdId,omitempty"` + VhdName *string `json:"vhdName,omitempty"` + VhdType *string `json:"vhdType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_diskencryptioninfo.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_diskencryptioninfo.go new file mode 100644 index 00000000000..57df685211a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_diskencryptioninfo.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionInfo struct { + DiskEncryptionKeyInfo *DiskEncryptionKeyInfo `json:"diskEncryptionKeyInfo,omitempty"` + KeyEncryptionKeyInfo *KeyEncryptionKeyInfo `json:"keyEncryptionKeyInfo,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_diskencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_diskencryptionkeyinfo.go new file mode 100644 index 00000000000..6ccd7c74d35 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_diskencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionKeyInfo struct { + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_enableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_enableprotectioninput.go new file mode 100644 index 00000000000..1fc5ffdfc7b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_enableprotectioninput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnableProtectionInput struct { + Properties *EnableProtectionInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_enableprotectioninputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_enableprotectioninputproperties.go new file mode 100644 index 00000000000..7993d8aa7cf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_enableprotectioninputproperties.go @@ -0,0 +1,45 @@ +package replicationprotecteditems + +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 EnableProtectionInputProperties struct { + PolicyId *string `json:"policyId,omitempty"` + ProtectableItemId *string `json:"protectableItemId,omitempty"` + ProviderSpecificDetails EnableProtectionProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &EnableProtectionInputProperties{} + +func (s *EnableProtectionInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + PolicyId *string `json:"policyId,omitempty"` + ProtectableItemId *string `json:"protectableItemId,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.PolicyId = decoded.PolicyId + s.ProtectableItemId = decoded.ProtectableItemId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling EnableProtectionInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalEnableProtectionProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'EnableProtectionInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_enableprotectionproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_enableprotectionproviderspecificinput.go new file mode 100644 index 00000000000..976ea1ce44f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_enableprotectionproviderspecificinput.go @@ -0,0 +1,115 @@ +package replicationprotecteditems + +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 EnableProtectionProviderSpecificInput interface { + EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl +} + +var _ EnableProtectionProviderSpecificInput = BaseEnableProtectionProviderSpecificInputImpl{} + +type BaseEnableProtectionProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseEnableProtectionProviderSpecificInputImpl) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return s +} + +var _ EnableProtectionProviderSpecificInput = RawEnableProtectionProviderSpecificInputImpl{} + +// RawEnableProtectionProviderSpecificInputImpl 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 RawEnableProtectionProviderSpecificInputImpl struct { + enableProtectionProviderSpecificInput BaseEnableProtectionProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawEnableProtectionProviderSpecificInputImpl) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return s.enableProtectionProviderSpecificInput +} + +func UnmarshalEnableProtectionProviderSpecificInputImplementation(input []byte) (EnableProtectionProviderSpecificInput, 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 EnableProtectionProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationEnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AEnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureEnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2EnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2EnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageEnableProtectionInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmEnableProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmEnableProtectionInput: %+v", err) + } + return out, nil + } + + var parent BaseEnableProtectionProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseEnableProtectionProviderSpecificInputImpl: %+v", err) + } + + return RawEnableProtectionProviderSpecificInputImpl{ + enableProtectionProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_healtherror.go new file mode 100644 index 00000000000..9b403536983 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationprotecteditems + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureapplyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureapplyrecoverypointinput.go new file mode 100644 index 00000000000..12d33abedde --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureapplyrecoverypointinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +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 _ ApplyRecoveryPointProviderSpecificInput = HyperVReplicaAzureApplyRecoveryPointInput{} + +type HyperVReplicaAzureApplyRecoveryPointInput struct { + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureApplyRecoveryPointInput) ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl { + return BaseApplyRecoveryPointProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureApplyRecoveryPointInput{} + +func (s HyperVReplicaAzureApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureApplyRecoveryPointInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazurediskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazurediskinputdetails.go new file mode 100644 index 00000000000..7aa638f016b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazurediskinputdetails.go @@ -0,0 +1,15 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HyperVReplicaAzureDiskInputDetails struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskSizeInGB *int64 `json:"diskSizeInGB,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + Iops *int64 `json:"iops,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + SectorSizeInBytes *int64 `json:"sectorSizeInBytes,omitempty"` + ThroughputInMbps *int64 `json:"throughputInMbps,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureenableprotectioninput.go new file mode 100644 index 00000000000..849a469b3df --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureenableprotectioninput.go @@ -0,0 +1,80 @@ +package replicationprotecteditems + +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 _ EnableProtectionProviderSpecificInput = HyperVReplicaAzureEnableProtectionInput{} + +type HyperVReplicaAzureEnableProtectionInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + DisksToInclude *[]string `json:"disksToInclude,omitempty"` + DisksToIncludeForManagedDisks *[]HyperVReplicaAzureDiskInputDetails `json:"disksToIncludeForManagedDisks,omitempty"` + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + HvHostVMId *string `json:"hvHostVmId,omitempty"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + OsType *string `json:"osType,omitempty"` + SeedManagedDiskTags *map[string]string `json:"seedManagedDiskTags,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetAzureNetworkId *string `json:"targetAzureNetworkId,omitempty"` + TargetAzureSubnetId *string `json:"targetAzureSubnetId,omitempty"` + TargetAzureV1ResourceGroupId *string `json:"targetAzureV1ResourceGroupId,omitempty"` + TargetAzureV2ResourceGroupId *string `json:"targetAzureV2ResourceGroupId,omitempty"` + TargetAzureVMName *string `json:"targetAzureVmName,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetStorageAccountId *string `json:"targetStorageAccountId,omitempty"` + TargetVMSecurityProfile *SecurityProfileProperties `json:"targetVmSecurityProfile,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + UseManagedDisksForReplication *string `json:"useManagedDisksForReplication,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` + VhdId *string `json:"vhdId,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureEnableProtectionInput) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return BaseEnableProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureEnableProtectionInput{} + +func (s HyperVReplicaAzureEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureEnableProtectionInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazurefailbackproviderinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazurefailbackproviderinput.go new file mode 100644 index 00000000000..94d265f86a2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazurefailbackproviderinput.go @@ -0,0 +1,52 @@ +package replicationprotecteditems + +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 _ PlannedFailoverProviderSpecificFailoverInput = HyperVReplicaAzureFailbackProviderInput{} + +type HyperVReplicaAzureFailbackProviderInput struct { + DataSyncOption *string `json:"dataSyncOption,omitempty"` + ProviderIdForAlternateRecovery *string `json:"providerIdForAlternateRecovery,omitempty"` + RecoveryVMCreationOption *string `json:"recoveryVmCreationOption,omitempty"` + + // Fields inherited from PlannedFailoverProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureFailbackProviderInput) PlannedFailoverProviderSpecificFailoverInput() BasePlannedFailoverProviderSpecificFailoverInputImpl { + return BasePlannedFailoverProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureFailbackProviderInput{} + +func (s HyperVReplicaAzureFailbackProviderInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureFailbackProviderInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureFailbackProviderInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureFailbackProviderInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzureFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureFailbackProviderInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazuremanageddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazuremanageddiskdetails.go new file mode 100644 index 00000000000..d9145abfeee --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazuremanageddiskdetails.go @@ -0,0 +1,16 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HyperVReplicaAzureManagedDiskDetails struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskSizeInGB *int64 `json:"diskSizeInGB,omitempty"` + Iops *int64 `json:"iops,omitempty"` + ReplicaDiskType *string `json:"replicaDiskType,omitempty"` + SectorSizeInBytes *int64 `json:"sectorSizeInBytes,omitempty"` + SeedManagedDiskId *string `json:"seedManagedDiskId,omitempty"` + TargetDiskAccountType *DiskAccountType `json:"targetDiskAccountType,omitempty"` + ThroughputInMbps *int64 `json:"throughputInMbps,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureplannedfailoverproviderinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureplannedfailoverproviderinput.go new file mode 100644 index 00000000000..839fa291aea --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureplannedfailoverproviderinput.go @@ -0,0 +1,53 @@ +package replicationprotecteditems + +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 _ PlannedFailoverProviderSpecificFailoverInput = HyperVReplicaAzurePlannedFailoverProviderInput{} + +type HyperVReplicaAzurePlannedFailoverProviderInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from PlannedFailoverProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzurePlannedFailoverProviderInput) PlannedFailoverProviderSpecificFailoverInput() BasePlannedFailoverProviderSpecificFailoverInputImpl { + return BasePlannedFailoverProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzurePlannedFailoverProviderInput{} + +func (s HyperVReplicaAzurePlannedFailoverProviderInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzurePlannedFailoverProviderInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzurePlannedFailoverProviderInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzurePlannedFailoverProviderInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzurePlannedFailoverProviderInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazurereplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazurereplicationdetails.go new file mode 100644 index 00000000000..65e383b091e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazurereplicationdetails.go @@ -0,0 +1,85 @@ +package replicationprotecteditems + +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 _ ReplicationProviderSpecificSettings = HyperVReplicaAzureReplicationDetails{} + +type HyperVReplicaAzureReplicationDetails struct { + AllAvailableOSUpgradeConfigurations *[]OSUpgradeSupportedVersions `json:"allAvailableOSUpgradeConfigurations,omitempty"` + AzureVMDiskDetails *[]AzureVMDiskDetails `json:"azureVmDiskDetails,omitempty"` + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + Encryption *string `json:"encryption,omitempty"` + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + LastRecoveryPointReceived *string `json:"lastRecoveryPointReceived,omitempty"` + LastReplicatedTime *string `json:"lastReplicatedTime,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + OSDetails *OSDetails `json:"oSDetails,omitempty"` + ProtectedManagedDisks *[]HyperVReplicaAzureManagedDiskDetails `json:"protectedManagedDisks,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAzureLogStorageAccountId *string `json:"recoveryAzureLogStorageAccountId,omitempty"` + RecoveryAzureResourceGroupId *string `json:"recoveryAzureResourceGroupId,omitempty"` + RecoveryAzureStorageAccount *string `json:"recoveryAzureStorageAccount,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVmName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SeedManagedDiskTags *map[string]string `json:"seedManagedDiskTags,omitempty"` + SelectedRecoveryAzureNetworkId *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + SelectedSourceNicId *string `json:"selectedSourceNicId,omitempty"` + SourceVMCPUCount *int64 `json:"sourceVmCpuCount,omitempty"` + SourceVMRamSizeInMB *int64 `json:"sourceVmRamSizeInMB,omitempty"` + SqlServerLicenseType *string `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMSecurityProfile *SecurityProfileProperties `json:"targetVmSecurityProfile,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureReplicationDetails{} + +func (s HyperVReplicaAzureReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazurereprotectinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazurereprotectinput.go new file mode 100644 index 00000000000..9627e00f825 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazurereprotectinput.go @@ -0,0 +1,55 @@ +package replicationprotecteditems + +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 _ ReverseReplicationProviderSpecificInput = HyperVReplicaAzureReprotectInput{} + +type HyperVReplicaAzureReprotectInput struct { + HvHostVMId *string `json:"hvHostVmId,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + OsType *string `json:"osType,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + VHDId *string `json:"vHDId,omitempty"` + VirtualMachineName *string `json:"vmName,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureReprotectInput) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return BaseReverseReplicationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureReprotectInput{} + +func (s HyperVReplicaAzureReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureReprotectInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazuretestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazuretestfailoverinput.go new file mode 100644 index 00000000000..155efe538d3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazuretestfailoverinput.go @@ -0,0 +1,53 @@ +package replicationprotecteditems + +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 _ TestFailoverProviderSpecificInput = HyperVReplicaAzureTestFailoverInput{} + +type HyperVReplicaAzureTestFailoverInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureTestFailoverInput) TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl { + return BaseTestFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureTestFailoverInput{} + +func (s HyperVReplicaAzureTestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureTestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureTestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureTestFailoverInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureTestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureunplannedfailoverinput.go new file mode 100644 index 00000000000..b0a3d75f455 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureunplannedfailoverinput.go @@ -0,0 +1,52 @@ +package replicationprotecteditems + +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 _ UnplannedFailoverProviderSpecificInput = HyperVReplicaAzureUnplannedFailoverInput{} + +type HyperVReplicaAzureUnplannedFailoverInput struct { + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureUnplannedFailoverInput) UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl { + return BaseUnplannedFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureUnplannedFailoverInput{} + +func (s HyperVReplicaAzureUnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureUnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureUnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureUnplannedFailoverInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureUnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureupdatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureupdatereplicationprotectediteminput.go new file mode 100644 index 00000000000..bcfa9cac1fc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicaazureupdatereplicationprotectediteminput.go @@ -0,0 +1,62 @@ +package replicationprotecteditems + +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 _ UpdateReplicationProtectedItemProviderInput = HyperVReplicaAzureUpdateReplicationProtectedItemInput{} + +type HyperVReplicaAzureUpdateReplicationProtectedItemInput struct { + DiskIdToDiskEncryptionMap *map[string]string `json:"diskIdToDiskEncryptionMap,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + RecoveryAzureV1ResourceGroupId *string `json:"recoveryAzureV1ResourceGroupId,omitempty"` + RecoveryAzureV2ResourceGroupId *string `json:"recoveryAzureV2ResourceGroupId,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` + VMDisks *[]UpdateDiskInput `json:"vmDisks,omitempty"` + + // Fields inherited from UpdateReplicationProtectedItemProviderInput + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaAzureUpdateReplicationProtectedItemInput) UpdateReplicationProtectedItemProviderInput() BaseUpdateReplicationProtectedItemProviderInputImpl { + return BaseUpdateReplicationProtectedItemProviderInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaAzureUpdateReplicationProtectedItemInput{} + +func (s HyperVReplicaAzureUpdateReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaAzureUpdateReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaAzureUpdateReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaAzureUpdateReplicationProtectedItemInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaAzureUpdateReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicabasereplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicabasereplicationdetails.go new file mode 100644 index 00000000000..e00c68803e4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicabasereplicationdetails.go @@ -0,0 +1,56 @@ +package replicationprotecteditems + +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 _ ReplicationProviderSpecificSettings = HyperVReplicaBaseReplicationDetails{} + +type HyperVReplicaBaseReplicationDetails struct { + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + LastReplicatedTime *string `json:"lastReplicatedTime,omitempty"` + VMDiskDetails *[]DiskDetails `json:"vMDiskDetails,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaBaseReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaBaseReplicationDetails{} + +func (s HyperVReplicaBaseReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBaseReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBaseReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBaseReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaBaseReplicationDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBaseReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicabluereplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicabluereplicationdetails.go new file mode 100644 index 00000000000..186d59debce --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicabluereplicationdetails.go @@ -0,0 +1,56 @@ +package replicationprotecteditems + +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 _ ReplicationProviderSpecificSettings = HyperVReplicaBlueReplicationDetails{} + +type HyperVReplicaBlueReplicationDetails struct { + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + LastReplicatedTime *string `json:"lastReplicatedTime,omitempty"` + VMDiskDetails *[]DiskDetails `json:"vMDiskDetails,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaBlueReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaBlueReplicationDetails{} + +func (s HyperVReplicaBlueReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaBlueReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaBlueReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaBlueReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012R2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaBlueReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicareplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicareplicationdetails.go new file mode 100644 index 00000000000..979c2bca833 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_hypervreplicareplicationdetails.go @@ -0,0 +1,56 @@ +package replicationprotecteditems + +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 _ ReplicationProviderSpecificSettings = HyperVReplicaReplicationDetails{} + +type HyperVReplicaReplicationDetails struct { + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + LastReplicatedTime *string `json:"lastReplicatedTime,omitempty"` + VMDiskDetails *[]DiskDetails `json:"vMDiskDetails,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s HyperVReplicaReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = HyperVReplicaReplicationDetails{} + +func (s HyperVReplicaReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper HyperVReplicaReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HyperVReplicaReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HyperVReplicaReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "HyperVReplica2012" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HyperVReplicaReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_initialreplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_initialreplicationdetails.go new file mode 100644 index 00000000000..62fc3a51fc8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_initialreplicationdetails.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InitialReplicationDetails struct { + InitialReplicationProgressPercentage *string `json:"initialReplicationProgressPercentage,omitempty"` + InitialReplicationType *string `json:"initialReplicationType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageagentdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageagentdetails.go new file mode 100644 index 00000000000..f899ff2af9d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageagentdetails.go @@ -0,0 +1,29 @@ +package replicationprotecteditems + +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 InMageAgentDetails struct { + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentUpdateStatus *string `json:"agentUpdateStatus,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + PostUpdateRebootStatus *string `json:"postUpdateRebootStatus,omitempty"` +} + +func (o *InMageAgentDetails) GetAgentExpiryDateAsTime() (*time.Time, error) { + if o.AgentExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageAgentDetails) SetAgentExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2applyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2applyrecoverypointinput.go new file mode 100644 index 00000000000..38010ccfe0d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2applyrecoverypointinput.go @@ -0,0 +1,49 @@ +package replicationprotecteditems + +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 _ ApplyRecoveryPointProviderSpecificInput = InMageAzureV2ApplyRecoveryPointInput{} + +type InMageAzureV2ApplyRecoveryPointInput struct { + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2ApplyRecoveryPointInput) ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl { + return BaseApplyRecoveryPointProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2ApplyRecoveryPointInput{} + +func (s InMageAzureV2ApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2ApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2ApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2ApplyRecoveryPointInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2ApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2diskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2diskinputdetails.go new file mode 100644 index 00000000000..608f4030e29 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2diskinputdetails.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageAzureV2DiskInputDetails struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2enableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2enableprotectioninput.go new file mode 100644 index 00000000000..d965ba09103 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2enableprotectioninput.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 _ EnableProtectionProviderSpecificInput = InMageAzureV2EnableProtectionInput{} + +type InMageAzureV2EnableProtectionInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + DisksToInclude *[]InMageAzureV2DiskInputDetails `json:"disksToInclude,omitempty"` + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + MasterTargetId *string `json:"masterTargetId,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + SeedManagedDiskTags *map[string]string `json:"seedManagedDiskTags,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetAzureNetworkId *string `json:"targetAzureNetworkId,omitempty"` + TargetAzureSubnetId *string `json:"targetAzureSubnetId,omitempty"` + TargetAzureV1ResourceGroupId *string `json:"targetAzureV1ResourceGroupId,omitempty"` + TargetAzureV2ResourceGroupId *string `json:"targetAzureV2ResourceGroupId,omitempty"` + TargetAzureVMName *string `json:"targetAzureVmName,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2EnableProtectionInput) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return BaseEnableProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2EnableProtectionInput{} + +func (s InMageAzureV2EnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2EnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2EnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2EnableProtectionInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2EnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2manageddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2manageddiskdetails.go new file mode 100644 index 00000000000..3ee19942044 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2manageddiskdetails.go @@ -0,0 +1,12 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageAzureV2ManagedDiskDetails struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + ReplicaDiskType *string `json:"replicaDiskType,omitempty"` + SeedManagedDiskId *string `json:"seedManagedDiskId,omitempty"` + TargetDiskName *string `json:"targetDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2protecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2protecteddiskdetails.go new file mode 100644 index 00000000000..95a2304ffef --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2protecteddiskdetails.go @@ -0,0 +1,72 @@ +package replicationprotecteditems + +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 InMageAzureV2ProtectedDiskDetails struct { + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` + FileSystemCapacityInBytes *int64 `json:"fileSystemCapacityInBytes,omitempty"` + HealthErrorCode *string `json:"healthErrorCode,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + ProgressHealth *string `json:"progressHealth,omitempty"` + ProgressStatus *string `json:"progressStatus,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + PsDataInMegaBytes *float64 `json:"psDataInMegaBytes,omitempty"` + ResyncDurationInSeconds *int64 `json:"resyncDurationInSeconds,omitempty"` + ResyncLast15MinutesTransferredBytes *int64 `json:"resyncLast15MinutesTransferredBytes,omitempty"` + ResyncLastDataTransferTimeUTC *string `json:"resyncLastDataTransferTimeUTC,omitempty"` + ResyncProcessedBytes *int64 `json:"resyncProcessedBytes,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncStartTime *string `json:"resyncStartTime,omitempty"` + ResyncTotalTransferredBytes *int64 `json:"resyncTotalTransferredBytes,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SecondsToTakeSwitchProvider *int64 `json:"secondsToTakeSwitchProvider,omitempty"` + SourceDataInMegaBytes *float64 `json:"sourceDataInMegaBytes,omitempty"` + TargetDataInMegaBytes *float64 `json:"targetDataInMegaBytes,omitempty"` +} + +func (o *InMageAzureV2ProtectedDiskDetails) GetLastRpoCalculatedTimeAsTime() (*time.Time, error) { + if o.LastRpoCalculatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRpoCalculatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageAzureV2ProtectedDiskDetails) SetLastRpoCalculatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRpoCalculatedTime = &formatted +} + +func (o *InMageAzureV2ProtectedDiskDetails) GetResyncLastDataTransferTimeUTCAsTime() (*time.Time, error) { + if o.ResyncLastDataTransferTimeUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResyncLastDataTransferTimeUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageAzureV2ProtectedDiskDetails) SetResyncLastDataTransferTimeUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResyncLastDataTransferTimeUTC = &formatted +} + +func (o *InMageAzureV2ProtectedDiskDetails) GetResyncStartTimeAsTime() (*time.Time, error) { + if o.ResyncStartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResyncStartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageAzureV2ProtectedDiskDetails) SetResyncStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResyncStartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2replicationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2replicationdetails.go new file mode 100644 index 00000000000..f1927aace2c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2replicationdetails.go @@ -0,0 +1,119 @@ +package replicationprotecteditems + +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 _ ReplicationProviderSpecificSettings = InMageAzureV2ReplicationDetails{} + +type InMageAzureV2ReplicationDetails struct { + AgentExpiryDate *string `json:"agentExpiryDate,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + AllAvailableOSUpgradeConfigurations *[]OSUpgradeSupportedVersions `json:"allAvailableOSUpgradeConfigurations,omitempty"` + AzureVMDiskDetails *[]AzureVMDiskDetails `json:"azureVMDiskDetails,omitempty"` + AzureVMGeneration *string `json:"azureVmGeneration,omitempty"` + CompressedDataRateInMB *float64 `json:"compressedDataRateInMB,omitempty"` + DataStores *[]string `json:"datastores,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + FirmwareType *string `json:"firmwareType,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InfrastructureVMId *string `json:"infrastructureVmId,omitempty"` + IsAdditionalStatsAvailable *bool `json:"isAdditionalStatsAvailable,omitempty"` + IsAgentUpdateRequired *string `json:"isAgentUpdateRequired,omitempty"` + IsRebootAfterUpdateRequired *string `json:"isRebootAfterUpdateRequired,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + LastRecoveryPointReceived *string `json:"lastRecoveryPointReceived,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LastUpdateReceivedTime *string `json:"lastUpdateReceivedTime,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + MasterTargetId *string `json:"masterTargetId,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + OsDiskId *string `json:"osDiskId,omitempty"` + OsName *string `json:"osName,omitempty"` + OsType *string `json:"osType,omitempty"` + OsVersion *string `json:"osVersion,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + ProcessServerName *string `json:"processServerName,omitempty"` + ProtectedDisks *[]InMageAzureV2ProtectedDiskDetails `json:"protectedDisks,omitempty"` + ProtectedManagedDisks *[]InMageAzureV2ManagedDiskDetails `json:"protectedManagedDisks,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAzureLogStorageAccountId *string `json:"recoveryAzureLogStorageAccountId,omitempty"` + RecoveryAzureResourceGroupId *string `json:"recoveryAzureResourceGroupId,omitempty"` + RecoveryAzureStorageAccount *string `json:"recoveryAzureStorageAccount,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + ReplicaId *string `json:"replicaId,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SeedManagedDiskTags *map[string]string `json:"seedManagedDiskTags,omitempty"` + SelectedRecoveryAzureNetworkId *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + SelectedSourceNicId *string `json:"selectedSourceNicId,omitempty"` + SelectedTfoAzureNetworkId *string `json:"selectedTfoAzureNetworkId,omitempty"` + SourceVMCPUCount *int64 `json:"sourceVmCpuCount,omitempty"` + SourceVMRamSizeInMB *int64 `json:"sourceVmRamSizeInMB,omitempty"` + SqlServerLicenseType *string `json:"sqlServerLicenseType,omitempty"` + SupportedOSVersions *[]string `json:"supportedOSVersions,omitempty"` + SwitchProviderBlockingErrorDetails *[]InMageAzureV2SwitchProviderBlockingErrorDetails `json:"switchProviderBlockingErrorDetails,omitempty"` + SwitchProviderDetails *InMageAzureV2SwitchProviderDetails `json:"switchProviderDetails,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMId *string `json:"targetVmId,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + TotalDataTransferred *int64 `json:"totalDataTransferred,omitempty"` + TotalProgressHealth *string `json:"totalProgressHealth,omitempty"` + UncompressedDataRateInMB *float64 `json:"uncompressedDataRateInMB,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + VCenterInfrastructureId *string `json:"vCenterInfrastructureId,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` + VhdName *string `json:"vhdName,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2ReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2ReplicationDetails{} + +func (s InMageAzureV2ReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2ReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2ReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2ReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2ReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2reprotectinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2reprotectinput.go new file mode 100644 index 00000000000..81dd163dc48 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2reprotectinput.go @@ -0,0 +1,56 @@ +package replicationprotecteditems + +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 _ ReverseReplicationProviderSpecificInput = InMageAzureV2ReprotectInput{} + +type InMageAzureV2ReprotectInput struct { + DisksToInclude *[]string `json:"disksToInclude,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + MasterTargetId *string `json:"masterTargetId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2ReprotectInput) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return BaseReverseReplicationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2ReprotectInput{} + +func (s InMageAzureV2ReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2ReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2ReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2ReprotectInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2ReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2switchproviderblockingerrordetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2switchproviderblockingerrordetails.go new file mode 100644 index 00000000000..d8507ad72aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2switchproviderblockingerrordetails.go @@ -0,0 +1,13 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageAzureV2SwitchProviderBlockingErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2switchproviderdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2switchproviderdetails.go new file mode 100644 index 00000000000..5c6e64b3e06 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2switchproviderdetails.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageAzureV2SwitchProviderDetails struct { + TargetApplianceId *string `json:"targetApplianceId,omitempty"` + TargetFabricId *string `json:"targetFabricId,omitempty"` + TargetResourceId *string `json:"targetResourceId,omitempty"` + TargetVaultId *string `json:"targetVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2switchproviderproviderinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2switchproviderproviderinput.go new file mode 100644 index 00000000000..15ae80129b4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2switchproviderproviderinput.go @@ -0,0 +1,52 @@ +package replicationprotecteditems + +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 _ SwitchProviderProviderSpecificInput = InMageAzureV2SwitchProviderProviderInput{} + +type InMageAzureV2SwitchProviderProviderInput struct { + TargetApplianceID string `json:"targetApplianceID"` + TargetFabricID string `json:"targetFabricID"` + TargetVaultID string `json:"targetVaultID"` + + // Fields inherited from SwitchProviderProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2SwitchProviderProviderInput) SwitchProviderProviderSpecificInput() BaseSwitchProviderProviderSpecificInputImpl { + return BaseSwitchProviderProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2SwitchProviderProviderInput{} + +func (s InMageAzureV2SwitchProviderProviderInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2SwitchProviderProviderInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2SwitchProviderProviderInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2SwitchProviderProviderInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2SwitchProviderProviderInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2testfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2testfailoverinput.go new file mode 100644 index 00000000000..b44c5ce60d2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2testfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +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 _ TestFailoverProviderSpecificInput = InMageAzureV2TestFailoverInput{} + +type InMageAzureV2TestFailoverInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2TestFailoverInput) TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl { + return BaseTestFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2TestFailoverInput{} + +func (s InMageAzureV2TestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2TestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2TestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2TestFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2TestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2unplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2unplannedfailoverinput.go new file mode 100644 index 00000000000..5f99b8cb9ef --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2unplannedfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +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 _ UnplannedFailoverProviderSpecificInput = InMageAzureV2UnplannedFailoverInput{} + +type InMageAzureV2UnplannedFailoverInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2UnplannedFailoverInput) UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl { + return BaseUnplannedFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2UnplannedFailoverInput{} + +func (s InMageAzureV2UnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2UnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2UnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2UnplannedFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2UnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2updatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2updatereplicationprotectediteminput.go new file mode 100644 index 00000000000..4a1f4a448d8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageazurev2updatereplicationprotectediteminput.go @@ -0,0 +1,59 @@ +package replicationprotecteditems + +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 _ UpdateReplicationProtectedItemProviderInput = InMageAzureV2UpdateReplicationProtectedItemInput{} + +type InMageAzureV2UpdateReplicationProtectedItemInput struct { + RecoveryAzureV1ResourceGroupId *string `json:"recoveryAzureV1ResourceGroupId,omitempty"` + RecoveryAzureV2ResourceGroupId *string `json:"recoveryAzureV2ResourceGroupId,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetManagedDiskTags *map[string]string `json:"targetManagedDiskTags,omitempty"` + TargetNicTags *map[string]string `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetVMTags *map[string]string `json:"targetVmTags,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + VMDisks *[]UpdateDiskInput `json:"vmDisks,omitempty"` + + // Fields inherited from UpdateReplicationProtectedItemProviderInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageAzureV2UpdateReplicationProtectedItemInput) UpdateReplicationProtectedItemProviderInput() BaseUpdateReplicationProtectedItemProviderInputImpl { + return BaseUpdateReplicationProtectedItemProviderInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageAzureV2UpdateReplicationProtectedItemInput{} + +func (s InMageAzureV2UpdateReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper InMageAzureV2UpdateReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageAzureV2UpdateReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageAzureV2UpdateReplicationProtectedItemInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageAzureV2UpdateReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagedisableprotectionproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagedisableprotectionproviderspecificinput.go new file mode 100644 index 00000000000..9f9b8923881 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagedisableprotectionproviderspecificinput.go @@ -0,0 +1,50 @@ +package replicationprotecteditems + +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 _ DisableProtectionProviderSpecificInput = InMageDisableProtectionProviderSpecificInput{} + +type InMageDisableProtectionProviderSpecificInput struct { + ReplicaVMDeletionStatus *string `json:"replicaVmDeletionStatus,omitempty"` + + // Fields inherited from DisableProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageDisableProtectionProviderSpecificInput) DisableProtectionProviderSpecificInput() BaseDisableProtectionProviderSpecificInputImpl { + return BaseDisableProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageDisableProtectionProviderSpecificInput{} + +func (s InMageDisableProtectionProviderSpecificInput) MarshalJSON() ([]byte, error) { + type wrapper InMageDisableProtectionProviderSpecificInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageDisableProtectionProviderSpecificInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageDisableProtectionProviderSpecificInput: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageDisableProtectionProviderSpecificInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagediskexclusioninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagediskexclusioninput.go new file mode 100644 index 00000000000..f43893e5555 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagediskexclusioninput.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageDiskExclusionInput struct { + DiskSignatureOptions *[]InMageDiskSignatureExclusionOptions `json:"diskSignatureOptions,omitempty"` + VolumeOptions *[]InMageVolumeExclusionOptions `json:"volumeOptions,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagedisksignatureexclusionoptions.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagedisksignatureexclusionoptions.go new file mode 100644 index 00000000000..4668154b630 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagedisksignatureexclusionoptions.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageDiskSignatureExclusionOptions struct { + DiskSignature *string `json:"diskSignature,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageenableprotectioninput.go new file mode 100644 index 00000000000..ecb43d87f50 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageenableprotectioninput.go @@ -0,0 +1,59 @@ +package replicationprotecteditems + +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 _ EnableProtectionProviderSpecificInput = InMageEnableProtectionInput{} + +type InMageEnableProtectionInput struct { + DatastoreName *string `json:"datastoreName,omitempty"` + DiskExclusionInput *InMageDiskExclusionInput `json:"diskExclusionInput,omitempty"` + DisksToInclude *[]string `json:"disksToInclude,omitempty"` + MasterTargetId string `json:"masterTargetId"` + MultiVMGroupId string `json:"multiVmGroupId"` + MultiVMGroupName string `json:"multiVmGroupName"` + ProcessServerId string `json:"processServerId"` + RetentionDrive string `json:"retentionDrive"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + VMFriendlyName *string `json:"vmFriendlyName,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageEnableProtectionInput) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return BaseEnableProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageEnableProtectionInput{} + +func (s InMageEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper InMageEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageEnableProtectionInput: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageprotecteddiskdetails.go new file mode 100644 index 00000000000..283ba9307e4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageprotecteddiskdetails.go @@ -0,0 +1,71 @@ +package replicationprotecteditems + +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 InMageProtectedDiskDetails struct { + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` + FileSystemCapacityInBytes *int64 `json:"fileSystemCapacityInBytes,omitempty"` + HealthErrorCode *string `json:"healthErrorCode,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + ProgressHealth *string `json:"progressHealth,omitempty"` + ProgressStatus *string `json:"progressStatus,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + PsDataInMB *float64 `json:"psDataInMB,omitempty"` + ResyncDurationInSeconds *int64 `json:"resyncDurationInSeconds,omitempty"` + ResyncLast15MinutesTransferredBytes *int64 `json:"resyncLast15MinutesTransferredBytes,omitempty"` + ResyncLastDataTransferTimeUTC *string `json:"resyncLastDataTransferTimeUTC,omitempty"` + ResyncProcessedBytes *int64 `json:"resyncProcessedBytes,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncStartTime *string `json:"resyncStartTime,omitempty"` + ResyncTotalTransferredBytes *int64 `json:"resyncTotalTransferredBytes,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SourceDataInMB *float64 `json:"sourceDataInMB,omitempty"` + TargetDataInMB *float64 `json:"targetDataInMB,omitempty"` +} + +func (o *InMageProtectedDiskDetails) GetLastRpoCalculatedTimeAsTime() (*time.Time, error) { + if o.LastRpoCalculatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRpoCalculatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageProtectedDiskDetails) SetLastRpoCalculatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRpoCalculatedTime = &formatted +} + +func (o *InMageProtectedDiskDetails) GetResyncLastDataTransferTimeUTCAsTime() (*time.Time, error) { + if o.ResyncLastDataTransferTimeUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResyncLastDataTransferTimeUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageProtectedDiskDetails) SetResyncLastDataTransferTimeUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResyncLastDataTransferTimeUTC = &formatted +} + +func (o *InMageProtectedDiskDetails) GetResyncStartTimeAsTime() (*time.Time, error) { + if o.ResyncStartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResyncStartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageProtectedDiskDetails) SetResyncStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResyncStartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmadddisksinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmadddisksinput.go new file mode 100644 index 00000000000..91b0bc63cf5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmadddisksinput.go @@ -0,0 +1,50 @@ +package replicationprotecteditems + +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 _ AddDisksProviderSpecificInput = InMageRcmAddDisksInput{} + +type InMageRcmAddDisksInput struct { + Disks []InMageRcmDiskInput `json:"disks"` + + // Fields inherited from AddDisksProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmAddDisksInput) AddDisksProviderSpecificInput() BaseAddDisksProviderSpecificInputImpl { + return BaseAddDisksProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmAddDisksInput{} + +func (s InMageRcmAddDisksInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmAddDisksInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmAddDisksInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmAddDisksInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmAddDisksInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmagentupgradeblockingerrordetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmagentupgradeblockingerrordetails.go new file mode 100644 index 00000000000..6235f92ce41 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmagentupgradeblockingerrordetails.go @@ -0,0 +1,13 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmAgentUpgradeBlockingErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmapplyrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmapplyrecoverypointinput.go new file mode 100644 index 00000000000..3f18666e7c5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmapplyrecoverypointinput.go @@ -0,0 +1,50 @@ +package replicationprotecteditems + +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 _ ApplyRecoveryPointProviderSpecificInput = InMageRcmApplyRecoveryPointInput{} + +type InMageRcmApplyRecoveryPointInput struct { + RecoveryPointId string `json:"recoveryPointId"` + + // Fields inherited from ApplyRecoveryPointProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmApplyRecoveryPointInput) ApplyRecoveryPointProviderSpecificInput() BaseApplyRecoveryPointProviderSpecificInputImpl { + return BaseApplyRecoveryPointProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmApplyRecoveryPointInput{} + +func (s InMageRcmApplyRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmApplyRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmApplyRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmApplyRecoveryPointInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmApplyRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmdiscoveredprotectedvmdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmdiscoveredprotectedvmdetails.go new file mode 100644 index 00000000000..345e3b53683 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmdiscoveredprotectedvmdetails.go @@ -0,0 +1,61 @@ +package replicationprotecteditems + +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 InMageRcmDiscoveredProtectedVMDetails struct { + CreatedTimestamp *string `json:"createdTimestamp,omitempty"` + DataStores *[]string `json:"datastores,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` + IsDeleted *bool `json:"isDeleted,omitempty"` + LastDiscoveryTimeInUtc *string `json:"lastDiscoveryTimeInUtc,omitempty"` + OsName *string `json:"osName,omitempty"` + PowerStatus *string `json:"powerStatus,omitempty"` + UpdatedTimestamp *string `json:"updatedTimestamp,omitempty"` + VCenterFqdn *string `json:"vCenterFqdn,omitempty"` + VCenterId *string `json:"vCenterId,omitempty"` + VMFqdn *string `json:"vmFqdn,omitempty"` + VMwareToolsStatus *string `json:"vmwareToolsStatus,omitempty"` +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) GetCreatedTimestampAsTime() (*time.Time, error) { + if o.CreatedTimestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTimestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) SetCreatedTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTimestamp = &formatted +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) GetLastDiscoveryTimeInUtcAsTime() (*time.Time, error) { + if o.LastDiscoveryTimeInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastDiscoveryTimeInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) SetLastDiscoveryTimeInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastDiscoveryTimeInUtc = &formatted +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) GetUpdatedTimestampAsTime() (*time.Time, error) { + if o.UpdatedTimestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.UpdatedTimestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmDiscoveredProtectedVMDetails) SetUpdatedTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.UpdatedTimestamp = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmdiskinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmdiskinput.go new file mode 100644 index 00000000000..5ee9474577e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmdiskinput.go @@ -0,0 +1,15 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmDiskInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId string `json:"diskId"` + DiskSizeInGB *int64 `json:"diskSizeInGB,omitempty"` + DiskType DiskAccountType `json:"diskType"` + Iops *int64 `json:"iops,omitempty"` + LogStorageAccountId string `json:"logStorageAccountId"` + SectorSizeInBytes *int64 `json:"sectorSizeInBytes,omitempty"` + ThroughputInMbps *int64 `json:"throughputInMbps,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmdisksdefaultinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmdisksdefaultinput.go new file mode 100644 index 00000000000..a54e7d0da30 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmdisksdefaultinput.go @@ -0,0 +1,14 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmDisksDefaultInput struct { + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskSizeInGB *int64 `json:"diskSizeInGB,omitempty"` + DiskType DiskAccountType `json:"diskType"` + Iops *int64 `json:"iops,omitempty"` + LogStorageAccountId string `json:"logStorageAccountId"` + SectorSizeInBytes *int64 `json:"sectorSizeInBytes,omitempty"` + ThroughputInMbps *int64 `json:"throughputInMbps,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmenableprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmenableprotectioninput.go new file mode 100644 index 00000000000..d1b1cad972c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmenableprotectioninput.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 _ EnableProtectionProviderSpecificInput = InMageRcmEnableProtectionInput{} + +type InMageRcmEnableProtectionInput struct { + DisksDefault *InMageRcmDisksDefaultInput `json:"disksDefault,omitempty"` + DisksToInclude *[]InMageRcmDiskInput `json:"disksToInclude,omitempty"` + FabricDiscoveryMachineId string `json:"fabricDiscoveryMachineId"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + ProcessServerId string `json:"processServerId"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + SeedManagedDiskTags *[]UserCreatedResourceTag `json:"seedManagedDiskTags,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetManagedDiskTags *[]UserCreatedResourceTag `json:"targetManagedDiskTags,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetNicTags *[]UserCreatedResourceTag `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId string `json:"targetResourceGroupId"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSecurityProfile *SecurityProfileProperties `json:"targetVmSecurityProfile,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *[]UserCreatedResourceTag `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` + + // Fields inherited from EnableProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmEnableProtectionInput) EnableProtectionProviderSpecificInput() BaseEnableProtectionProviderSpecificInputImpl { + return BaseEnableProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmEnableProtectionInput{} + +func (s InMageRcmEnableProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmEnableProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmEnableProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmEnableProtectionInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmEnableProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackdiscoveredprotectedvmdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackdiscoveredprotectedvmdetails.go new file mode 100644 index 00000000000..e90a52a1048 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackdiscoveredprotectedvmdetails.go @@ -0,0 +1,61 @@ +package replicationprotecteditems + +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 InMageRcmFailbackDiscoveredProtectedVMDetails struct { + CreatedTimestamp *string `json:"createdTimestamp,omitempty"` + DataStores *[]string `json:"datastores,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` + IsDeleted *bool `json:"isDeleted,omitempty"` + LastDiscoveryTimeInUtc *string `json:"lastDiscoveryTimeInUtc,omitempty"` + OsName *string `json:"osName,omitempty"` + PowerStatus *string `json:"powerStatus,omitempty"` + UpdatedTimestamp *string `json:"updatedTimestamp,omitempty"` + VCenterFqdn *string `json:"vCenterFqdn,omitempty"` + VCenterId *string `json:"vCenterId,omitempty"` + VMFqdn *string `json:"vmFqdn,omitempty"` + VMwareToolsStatus *string `json:"vmwareToolsStatus,omitempty"` +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) GetCreatedTimestampAsTime() (*time.Time, error) { + if o.CreatedTimestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTimestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) SetCreatedTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTimestamp = &formatted +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) GetLastDiscoveryTimeInUtcAsTime() (*time.Time, error) { + if o.LastDiscoveryTimeInUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastDiscoveryTimeInUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) SetLastDiscoveryTimeInUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastDiscoveryTimeInUtc = &formatted +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) GetUpdatedTimestampAsTime() (*time.Time, error) { + if o.UpdatedTimestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.UpdatedTimestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackDiscoveredProtectedVMDetails) SetUpdatedTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.UpdatedTimestamp = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackmobilityagentdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackmobilityagentdetails.go new file mode 100644 index 00000000000..6ef3f5e7b37 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackmobilityagentdetails.go @@ -0,0 +1,58 @@ +package replicationprotecteditems + +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 InMageRcmFailbackMobilityAgentDetails struct { + AgentVersionExpiryDate *string `json:"agentVersionExpiryDate,omitempty"` + DriverVersion *string `json:"driverVersion,omitempty"` + DriverVersionExpiryDate *string `json:"driverVersionExpiryDate,omitempty"` + IsUpgradeable *string `json:"isUpgradeable,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + LatestUpgradableVersionWithoutReboot *string `json:"latestUpgradableVersionWithoutReboot,omitempty"` + LatestVersion *string `json:"latestVersion,omitempty"` + ReasonsBlockingUpgrade *[]AgentUpgradeBlockedReason `json:"reasonsBlockingUpgrade,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *InMageRcmFailbackMobilityAgentDetails) GetAgentVersionExpiryDateAsTime() (*time.Time, error) { + if o.AgentVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackMobilityAgentDetails) SetAgentVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentVersionExpiryDate = &formatted +} + +func (o *InMageRcmFailbackMobilityAgentDetails) GetDriverVersionExpiryDateAsTime() (*time.Time, error) { + if o.DriverVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DriverVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackMobilityAgentDetails) SetDriverVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DriverVersionExpiryDate = &formatted +} + +func (o *InMageRcmFailbackMobilityAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackMobilityAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbacknicdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbacknicdetails.go new file mode 100644 index 00000000000..44ac3499256 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbacknicdetails.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmFailbackNicDetails struct { + AdapterType *string `json:"adapterType,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + NetworkName *string `json:"networkName,omitempty"` + SourceIPAddress *string `json:"sourceIpAddress,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackplannedfailoverproviderinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackplannedfailoverproviderinput.go new file mode 100644 index 00000000000..f347a8ab887 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackplannedfailoverproviderinput.go @@ -0,0 +1,50 @@ +package replicationprotecteditems + +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 _ PlannedFailoverProviderSpecificFailoverInput = InMageRcmFailbackPlannedFailoverProviderInput{} + +type InMageRcmFailbackPlannedFailoverProviderInput struct { + RecoveryPointType InMageRcmFailbackRecoveryPointType `json:"recoveryPointType"` + + // Fields inherited from PlannedFailoverProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFailbackPlannedFailoverProviderInput) PlannedFailoverProviderSpecificFailoverInput() BasePlannedFailoverProviderSpecificFailoverInputImpl { + return BasePlannedFailoverProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFailbackPlannedFailoverProviderInput{} + +func (s InMageRcmFailbackPlannedFailoverProviderInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackPlannedFailoverProviderInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackPlannedFailoverProviderInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackPlannedFailoverProviderInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackPlannedFailoverProviderInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackprotecteddiskdetails.go new file mode 100644 index 00000000000..0d93a99814a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackprotecteddiskdetails.go @@ -0,0 +1,36 @@ +package replicationprotecteditems + +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 InMageRcmFailbackProtectedDiskDetails struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` + DataPendingInLogDataStoreInMB *float64 `json:"dataPendingInLogDataStoreInMB,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskUuid *string `json:"diskUuid,omitempty"` + IrDetails *InMageRcmFailbackSyncDetails `json:"irDetails,omitempty"` + IsInitialReplicationComplete *string `json:"isInitialReplicationComplete,omitempty"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + LastSyncTime *string `json:"lastSyncTime,omitempty"` + ResyncDetails *InMageRcmFailbackSyncDetails `json:"resyncDetails,omitempty"` +} + +func (o *InMageRcmFailbackProtectedDiskDetails) GetLastSyncTimeAsTime() (*time.Time, error) { + if o.LastSyncTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastSyncTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmFailbackProtectedDiskDetails) SetLastSyncTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastSyncTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackreplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackreplicationdetails.go new file mode 100644 index 00000000000..d0312afb7b2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackreplicationdetails.go @@ -0,0 +1,78 @@ +package replicationprotecteditems + +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 _ ReplicationProviderSpecificSettings = InMageRcmFailbackReplicationDetails{} + +type InMageRcmFailbackReplicationDetails struct { + AzureVirtualMachineId *string `json:"azureVirtualMachineId,omitempty"` + DiscoveredVMDetails *InMageRcmFailbackDiscoveredProtectedVMDetails `json:"discoveredVmDetails,omitempty"` + InitialReplicationProcessedBytes *int64 `json:"initialReplicationProcessedBytes,omitempty"` + InitialReplicationProgressHealth *VMReplicationProgressHealth `json:"initialReplicationProgressHealth,omitempty"` + InitialReplicationProgressPercentage *int64 `json:"initialReplicationProgressPercentage,omitempty"` + InitialReplicationTransferredBytes *int64 `json:"initialReplicationTransferredBytes,omitempty"` + InternalIdentifier *string `json:"internalIdentifier,omitempty"` + IsAgentRegistrationSuccessfulAfterFailover *bool `json:"isAgentRegistrationSuccessfulAfterFailover,omitempty"` + LastPlannedFailoverStartTime *string `json:"lastPlannedFailoverStartTime,omitempty"` + LastPlannedFailoverStatus *PlannedFailoverStatus `json:"lastPlannedFailoverStatus,omitempty"` + LastUsedPolicyFriendlyName *string `json:"lastUsedPolicyFriendlyName,omitempty"` + LastUsedPolicyId *string `json:"lastUsedPolicyId,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + MobilityAgentDetails *InMageRcmFailbackMobilityAgentDetails `json:"mobilityAgentDetails,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + OsType *string `json:"osType,omitempty"` + ProtectedDisks *[]InMageRcmFailbackProtectedDiskDetails `json:"protectedDisks,omitempty"` + ReprotectAgentId *string `json:"reprotectAgentId,omitempty"` + ReprotectAgentName *string `json:"reprotectAgentName,omitempty"` + ResyncProcessedBytes *int64 `json:"resyncProcessedBytes,omitempty"` + ResyncProgressHealth *VMReplicationProgressHealth `json:"resyncProgressHealth,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncState *ResyncState `json:"resyncState,omitempty"` + ResyncTransferredBytes *int64 `json:"resyncTransferredBytes,omitempty"` + TargetDataStoreName *string `json:"targetDataStoreName,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetvCenterId *string `json:"targetvCenterId,omitempty"` + VMNics *[]InMageRcmFailbackNicDetails `json:"vmNics,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFailbackReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFailbackReplicationDetails{} + +func (s InMageRcmFailbackReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackreprotectinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackreprotectinput.go new file mode 100644 index 00000000000..25a4835498d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbackreprotectinput.go @@ -0,0 +1,52 @@ +package replicationprotecteditems + +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 _ ReverseReplicationProviderSpecificInput = InMageRcmFailbackReprotectInput{} + +type InMageRcmFailbackReprotectInput struct { + PolicyId string `json:"policyId"` + ProcessServerId string `json:"processServerId"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmFailbackReprotectInput) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return BaseReverseReplicationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmFailbackReprotectInput{} + +func (s InMageRcmFailbackReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmFailbackReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmFailbackReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmFailbackReprotectInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmFailbackReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbacksyncdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbacksyncdetails.go new file mode 100644 index 00000000000..5451ccadcf1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmfailbacksyncdetails.go @@ -0,0 +1,15 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmFailbackSyncDetails struct { + Last15MinutesTransferredBytes *int64 `json:"last15MinutesTransferredBytes,omitempty"` + LastDataTransferTimeUtc *string `json:"lastDataTransferTimeUtc,omitempty"` + LastRefreshTime *string `json:"lastRefreshTime,omitempty"` + ProcessedBytes *int64 `json:"processedBytes,omitempty"` + ProgressHealth *DiskReplicationProgressHealth `json:"progressHealth,omitempty"` + ProgressPercentage *int64 `json:"progressPercentage,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TransferredBytes *int64 `json:"transferredBytes,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmlastagentupgradeerrordetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmlastagentupgradeerrordetails.go new file mode 100644 index 00000000000..8e87e3b48bc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmlastagentupgradeerrordetails.go @@ -0,0 +1,13 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmLastAgentUpgradeErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorMessageParameters *map[string]string `json:"errorMessageParameters,omitempty"` + ErrorTags *map[string]string `json:"errorTags,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmmobilityagentdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmmobilityagentdetails.go new file mode 100644 index 00000000000..bc2431c22ae --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmmobilityagentdetails.go @@ -0,0 +1,59 @@ +package replicationprotecteditems + +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 InMageRcmMobilityAgentDetails struct { + AgentVersionExpiryDate *string `json:"agentVersionExpiryDate,omitempty"` + DriverVersion *string `json:"driverVersion,omitempty"` + DriverVersionExpiryDate *string `json:"driverVersionExpiryDate,omitempty"` + IsUpgradeable *string `json:"isUpgradeable,omitempty"` + LastHeartbeatUtc *string `json:"lastHeartbeatUtc,omitempty"` + LatestAgentReleaseDate *string `json:"latestAgentReleaseDate,omitempty"` + LatestUpgradableVersionWithoutReboot *string `json:"latestUpgradableVersionWithoutReboot,omitempty"` + LatestVersion *string `json:"latestVersion,omitempty"` + ReasonsBlockingUpgrade *[]AgentUpgradeBlockedReason `json:"reasonsBlockingUpgrade,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *InMageRcmMobilityAgentDetails) GetAgentVersionExpiryDateAsTime() (*time.Time, error) { + if o.AgentVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgentVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmMobilityAgentDetails) SetAgentVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgentVersionExpiryDate = &formatted +} + +func (o *InMageRcmMobilityAgentDetails) GetDriverVersionExpiryDateAsTime() (*time.Time, error) { + if o.DriverVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DriverVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmMobilityAgentDetails) SetDriverVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DriverVersionExpiryDate = &formatted +} + +func (o *InMageRcmMobilityAgentDetails) GetLastHeartbeatUtcAsTime() (*time.Time, error) { + if o.LastHeartbeatUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeatUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InMageRcmMobilityAgentDetails) SetLastHeartbeatUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeatUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmnicdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmnicdetails.go new file mode 100644 index 00000000000..2bfbf3a3e98 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmnicdetails.go @@ -0,0 +1,21 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmNicDetails struct { + IsPrimaryNic *string `json:"isPrimaryNic,omitempty"` + IsSelectedForFailover *string `json:"isSelectedForFailover,omitempty"` + NicId *string `json:"nicId,omitempty"` + SourceIPAddress *string `json:"sourceIPAddress,omitempty"` + SourceIPAddressType *EthernetAddressType `json:"sourceIPAddressType,omitempty"` + SourceNetworkId *string `json:"sourceNetworkId,omitempty"` + SourceSubnetName *string `json:"sourceSubnetName,omitempty"` + TargetIPAddress *string `json:"targetIPAddress,omitempty"` + TargetIPAddressType *EthernetAddressType `json:"targetIPAddressType,omitempty"` + TargetNicName *string `json:"targetNicName,omitempty"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TestIPAddress *string `json:"testIPAddress,omitempty"` + TestIPAddressType *EthernetAddressType `json:"testIPAddressType,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmnicinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmnicinput.go new file mode 100644 index 00000000000..2f632b4a8f1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmnicinput.go @@ -0,0 +1,15 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmNicInput struct { + IsPrimaryNic string `json:"isPrimaryNic"` + IsSelectedForFailover *string `json:"isSelectedForFailover,omitempty"` + NicId string `json:"nicId"` + TargetNicName *string `json:"targetNicName,omitempty"` + TargetStaticIPAddress *string `json:"targetStaticIPAddress,omitempty"` + TargetSubnetName *string `json:"targetSubnetName,omitempty"` + TestStaticIPAddress *string `json:"testStaticIPAddress,omitempty"` + TestSubnetName *string `json:"testSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmprotecteddiskdetails.go new file mode 100644 index 00000000000..98d7fc93576 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmprotecteddiskdetails.go @@ -0,0 +1,28 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmProtectedDiskDetails struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + CustomTargetDiskName *string `json:"customTargetDiskName,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` + DataPendingInLogDataStoreInMB *float64 `json:"dataPendingInLogDataStoreInMB,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskSizeInGB *int64 `json:"diskSizeInGB,omitempty"` + DiskState *DiskState `json:"diskState,omitempty"` + DiskType *DiskAccountType `json:"diskType,omitempty"` + Iops *int64 `json:"iops,omitempty"` + IrDetails *InMageRcmSyncDetails `json:"irDetails,omitempty"` + IsInitialReplicationComplete *string `json:"isInitialReplicationComplete,omitempty"` + IsOSDisk *string `json:"isOSDisk,omitempty"` + LogStorageAccountId *string `json:"logStorageAccountId,omitempty"` + ResyncDetails *InMageRcmSyncDetails `json:"resyncDetails,omitempty"` + SectorSizeInBytes *int64 `json:"sectorSizeInBytes,omitempty"` + SeedBlobUri *string `json:"seedBlobUri,omitempty"` + SeedManagedDiskId *string `json:"seedManagedDiskId,omitempty"` + TargetManagedDiskId *string `json:"targetManagedDiskId,omitempty"` + ThroughputInMbps *int64 `json:"throughputInMbps,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmreplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmreplicationdetails.go new file mode 100644 index 00000000000..f2290953258 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmreplicationdetails.go @@ -0,0 +1,111 @@ +package replicationprotecteditems + +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 _ ReplicationProviderSpecificSettings = InMageRcmReplicationDetails{} + +type InMageRcmReplicationDetails struct { + AgentUpgradeAttemptToVersion *string `json:"agentUpgradeAttemptToVersion,omitempty"` + AgentUpgradeBlockingErrorDetails *[]InMageRcmAgentUpgradeBlockingErrorDetails `json:"agentUpgradeBlockingErrorDetails,omitempty"` + AgentUpgradeJobId *string `json:"agentUpgradeJobId,omitempty"` + AgentUpgradeState *MobilityAgentUpgradeState `json:"agentUpgradeState,omitempty"` + AllocatedMemoryInMB *float64 `json:"allocatedMemoryInMB,omitempty"` + DiscoveredVMDetails *InMageRcmDiscoveredProtectedVMDetails `json:"discoveredVmDetails,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + FabricDiscoveryMachineId *string `json:"fabricDiscoveryMachineId,omitempty"` + FailoverRecoveryPointId *string `json:"failoverRecoveryPointId,omitempty"` + FirmwareType *string `json:"firmwareType,omitempty"` + InitialReplicationProcessedBytes *int64 `json:"initialReplicationProcessedBytes,omitempty"` + InitialReplicationProgressHealth *VMReplicationProgressHealth `json:"initialReplicationProgressHealth,omitempty"` + InitialReplicationProgressPercentage *int64 `json:"initialReplicationProgressPercentage,omitempty"` + InitialReplicationTransferredBytes *int64 `json:"initialReplicationTransferredBytes,omitempty"` + InternalIdentifier *string `json:"internalIdentifier,omitempty"` + IsAgentRegistrationSuccessfulAfterFailover *bool `json:"isAgentRegistrationSuccessfulAfterFailover,omitempty"` + IsLastUpgradeSuccessful *string `json:"isLastUpgradeSuccessful,omitempty"` + LastAgentUpgradeErrorDetails *[]InMageRcmLastAgentUpgradeErrorDetails `json:"lastAgentUpgradeErrorDetails,omitempty"` + LastAgentUpgradeType *string `json:"lastAgentUpgradeType,omitempty"` + LastRecoveryPointId *string `json:"lastRecoveryPointId,omitempty"` + LastRecoveryPointReceived *string `json:"lastRecoveryPointReceived,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LastRpoInSeconds *int64 `json:"lastRpoInSeconds,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + MobilityAgentDetails *InMageRcmMobilityAgentDetails `json:"mobilityAgentDetails,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + OsName *string `json:"osName,omitempty"` + OsType *string `json:"osType,omitempty"` + PrimaryNicIPAddress *string `json:"primaryNicIpAddress,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + ProcessServerName *string `json:"processServerName,omitempty"` + ProcessorCoreCount *int64 `json:"processorCoreCount,omitempty"` + ProtectedDisks *[]InMageRcmProtectedDiskDetails `json:"protectedDisks,omitempty"` + ResyncProcessedBytes *int64 `json:"resyncProcessedBytes,omitempty"` + ResyncProgressHealth *VMReplicationProgressHealth `json:"resyncProgressHealth,omitempty"` + ResyncProgressPercentage *int64 `json:"resyncProgressPercentage,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncState *ResyncState `json:"resyncState,omitempty"` + ResyncTransferredBytes *int64 `json:"resyncTransferredBytes,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + SeedManagedDiskTags *[]UserCreatedResourceTag `json:"seedManagedDiskTags,omitempty"` + SqlServerLicenseType *string `json:"sqlServerLicenseType,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SupportedOSVersions *[]string `json:"supportedOSVersions,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetGeneration *string `json:"targetGeneration,omitempty"` + TargetLocation *string `json:"targetLocation,omitempty"` + TargetManagedDiskTags *[]UserCreatedResourceTag `json:"targetManagedDiskTags,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetNicTags *[]UserCreatedResourceTag `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSecurityProfile *SecurityProfileProperties `json:"targetVmSecurityProfile,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *[]UserCreatedResourceTag `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + UnprotectedDisks *[]InMageRcmUnProtectedDiskDetails `json:"unprotectedDisks,omitempty"` + VMNics *[]InMageRcmNicDetails `json:"vmNics,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmReplicationDetails{} + +func (s InMageRcmReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmreprotectinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmreprotectinput.go new file mode 100644 index 00000000000..a8a70b3cef6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmreprotectinput.go @@ -0,0 +1,53 @@ +package replicationprotecteditems + +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 _ ReverseReplicationProviderSpecificInput = InMageRcmReprotectInput{} + +type InMageRcmReprotectInput struct { + DatastoreName string `json:"datastoreName"` + LogStorageAccountId string `json:"logStorageAccountId"` + PolicyId *string `json:"policyId,omitempty"` + ReprotectAgentId string `json:"reprotectAgentId"` + + // Fields inherited from ReverseReplicationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmReprotectInput) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return BaseReverseReplicationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmReprotectInput{} + +func (s InMageRcmReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmReprotectInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmsyncdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmsyncdetails.go new file mode 100644 index 00000000000..a8388f3c5f8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmsyncdetails.go @@ -0,0 +1,15 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmSyncDetails struct { + Last15MinutesTransferredBytes *int64 `json:"last15MinutesTransferredBytes,omitempty"` + LastDataTransferTimeUtc *string `json:"lastDataTransferTimeUtc,omitempty"` + LastRefreshTime *string `json:"lastRefreshTime,omitempty"` + ProcessedBytes *int64 `json:"processedBytes,omitempty"` + ProgressHealth *DiskReplicationProgressHealth `json:"progressHealth,omitempty"` + ProgressPercentage *int64 `json:"progressPercentage,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TransferredBytes *int64 `json:"transferredBytes,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmtestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmtestfailoverinput.go new file mode 100644 index 00000000000..92af54992fb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmtestfailoverinput.go @@ -0,0 +1,52 @@ +package replicationprotecteditems + +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 _ TestFailoverProviderSpecificInput = InMageRcmTestFailoverInput{} + +type InMageRcmTestFailoverInput struct { + NetworkId *string `json:"networkId,omitempty"` + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmTestFailoverInput) TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl { + return BaseTestFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmTestFailoverInput{} + +func (s InMageRcmTestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmTestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmTestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmTestFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmTestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmunplannedfailoverinput.go new file mode 100644 index 00000000000..1d2555610f6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmunplannedfailoverinput.go @@ -0,0 +1,52 @@ +package replicationprotecteditems + +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 _ UnplannedFailoverProviderSpecificInput = InMageRcmUnplannedFailoverInput{} + +type InMageRcmUnplannedFailoverInput struct { + OsUpgradeVersion *string `json:"osUpgradeVersion,omitempty"` + PerformShutdown string `json:"performShutdown"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmUnplannedFailoverInput) UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl { + return BaseUnplannedFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmUnplannedFailoverInput{} + +func (s InMageRcmUnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmUnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmUnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmUnplannedFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmUnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmunprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmunprotecteddiskdetails.go new file mode 100644 index 00000000000..95242854fa8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmunprotecteddiskdetails.go @@ -0,0 +1,10 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageRcmUnProtectedDiskDetails struct { + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmupdateapplianceforreplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmupdateapplianceforreplicationprotectediteminput.go new file mode 100644 index 00000000000..c3eb7e50380 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmupdateapplianceforreplicationprotectediteminput.go @@ -0,0 +1,50 @@ +package replicationprotecteditems + +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 _ UpdateApplianceForReplicationProtectedItemProviderSpecificInput = InMageRcmUpdateApplianceForReplicationProtectedItemInput{} + +type InMageRcmUpdateApplianceForReplicationProtectedItemInput struct { + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + + // Fields inherited from UpdateApplianceForReplicationProtectedItemProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmUpdateApplianceForReplicationProtectedItemInput) UpdateApplianceForReplicationProtectedItemProviderSpecificInput() BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl { + return BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmUpdateApplianceForReplicationProtectedItemInput{} + +func (s InMageRcmUpdateApplianceForReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmUpdateApplianceForReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmUpdateApplianceForReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmUpdateApplianceForReplicationProtectedItemInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmUpdateApplianceForReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmupdatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmupdatereplicationprotectediteminput.go new file mode 100644 index 00000000000..a2a90639cc5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagercmupdatereplicationprotectediteminput.go @@ -0,0 +1,66 @@ +package replicationprotecteditems + +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 _ UpdateReplicationProtectedItemProviderInput = InMageRcmUpdateReplicationProtectedItemInput{} + +type InMageRcmUpdateReplicationProtectedItemInput struct { + LicenseType *LicenseType `json:"licenseType,omitempty"` + LinuxLicenseType *LinuxLicenseType `json:"linuxLicenseType,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + TargetAvailabilitySetId *string `json:"targetAvailabilitySetId,omitempty"` + TargetAvailabilityZone *string `json:"targetAvailabilityZone,omitempty"` + TargetBootDiagnosticsStorageAccountId *string `json:"targetBootDiagnosticsStorageAccountId,omitempty"` + TargetManagedDiskTags *[]UserCreatedResourceTag `json:"targetManagedDiskTags,omitempty"` + TargetNetworkId *string `json:"targetNetworkId,omitempty"` + TargetNicTags *[]UserCreatedResourceTag `json:"targetNicTags,omitempty"` + TargetProximityPlacementGroupId *string `json:"targetProximityPlacementGroupId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVMName *string `json:"targetVmName,omitempty"` + TargetVMSize *string `json:"targetVmSize,omitempty"` + TargetVMTags *[]UserCreatedResourceTag `json:"targetVmTags,omitempty"` + TestNetworkId *string `json:"testNetworkId,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` + VMNics *[]InMageRcmNicInput `json:"vmNics,omitempty"` + + // Fields inherited from UpdateReplicationProtectedItemProviderInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmUpdateReplicationProtectedItemInput) UpdateReplicationProtectedItemProviderInput() BaseUpdateReplicationProtectedItemProviderInputImpl { + return BaseUpdateReplicationProtectedItemProviderInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmUpdateReplicationProtectedItemInput{} + +func (s InMageRcmUpdateReplicationProtectedItemInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmUpdateReplicationProtectedItemInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmUpdateReplicationProtectedItemInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmUpdateReplicationProtectedItemInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmUpdateReplicationProtectedItemInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagereplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagereplicationdetails.go new file mode 100644 index 00000000000..5bd28404fcb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagereplicationdetails.go @@ -0,0 +1,89 @@ +package replicationprotecteditems + +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 _ ReplicationProviderSpecificSettings = InMageReplicationDetails{} + +type InMageReplicationDetails struct { + ActiveSiteType *string `json:"activeSiteType,omitempty"` + AgentDetails *InMageAgentDetails `json:"agentDetails,omitempty"` + AzureStorageAccountId *string `json:"azureStorageAccountId,omitempty"` + CompressedDataRateInMB *float64 `json:"compressedDataRateInMB,omitempty"` + ConsistencyPoints *map[string]string `json:"consistencyPoints,omitempty"` + DataStores *[]string `json:"datastores,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InfrastructureVMId *string `json:"infrastructureVmId,omitempty"` + IsAdditionalStatsAvailable *bool `json:"isAdditionalStatsAvailable,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LastUpdateReceivedTime *string `json:"lastUpdateReceivedTime,omitempty"` + MasterTargetId *string `json:"masterTargetId,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + OsDetails *OSDiskDetails `json:"osDetails,omitempty"` + OsVersion *string `json:"osVersion,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + ProtectedDisks *[]InMageProtectedDiskDetails `json:"protectedDisks,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + RebootAfterUpdateStatus *string `json:"rebootAfterUpdateStatus,omitempty"` + ReplicaId *string `json:"replicaId,omitempty"` + ResyncDetails *InitialReplicationDetails `json:"resyncDetails,omitempty"` + RetentionWindowEnd *string `json:"retentionWindowEnd,omitempty"` + RetentionWindowStart *string `json:"retentionWindowStart,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SourceVMCPUCount *int64 `json:"sourceVmCpuCount,omitempty"` + SourceVMRamSizeInMB *int64 `json:"sourceVmRamSizeInMB,omitempty"` + TotalDataTransferred *int64 `json:"totalDataTransferred,omitempty"` + TotalProgressHealth *string `json:"totalProgressHealth,omitempty"` + UncompressedDataRateInMB *float64 `json:"uncompressedDataRateInMB,omitempty"` + VCenterInfrastructureId *string `json:"vCenterInfrastructureId,omitempty"` + VMId *string `json:"vmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` + + // Fields inherited from ReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s InMageReplicationDetails) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return BaseReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageReplicationDetails{} + +func (s InMageReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagereprotectinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagereprotectinput.go new file mode 100644 index 00000000000..f7f46d7e03c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagereprotectinput.go @@ -0,0 +1,57 @@ +package replicationprotecteditems + +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 _ ReverseReplicationProviderSpecificInput = InMageReprotectInput{} + +type InMageReprotectInput struct { + DatastoreName *string `json:"datastoreName,omitempty"` + DiskExclusionInput *InMageDiskExclusionInput `json:"diskExclusionInput,omitempty"` + DisksToInclude *[]string `json:"disksToInclude,omitempty"` + MasterTargetId string `json:"masterTargetId"` + ProcessServerId string `json:"processServerId"` + ProfileId string `json:"profileId"` + RetentionDrive string `json:"retentionDrive"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` + + // Fields inherited from ReverseReplicationProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageReprotectInput) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return BaseReverseReplicationProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageReprotectInput{} + +func (s InMageReprotectInput) MarshalJSON() ([]byte, error) { + type wrapper InMageReprotectInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageReprotectInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageReprotectInput: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageReprotectInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagetestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagetestfailoverinput.go new file mode 100644 index 00000000000..c2c3cb6b741 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagetestfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +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 _ TestFailoverProviderSpecificInput = InMageTestFailoverInput{} + +type InMageTestFailoverInput struct { + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointType *RecoveryPointType `json:"recoveryPointType,omitempty"` + + // Fields inherited from TestFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageTestFailoverInput) TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl { + return BaseTestFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageTestFailoverInput{} + +func (s InMageTestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageTestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageTestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageTestFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageTestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageunplannedfailoverinput.go new file mode 100644 index 00000000000..9d97383ad62 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmageunplannedfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotecteditems + +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 _ UnplannedFailoverProviderSpecificInput = InMageUnplannedFailoverInput{} + +type InMageUnplannedFailoverInput struct { + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointType *RecoveryPointType `json:"recoveryPointType,omitempty"` + + // Fields inherited from UnplannedFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageUnplannedFailoverInput) UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl { + return BaseUnplannedFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageUnplannedFailoverInput{} + +func (s InMageUnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper InMageUnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageUnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageUnplannedFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageUnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagevolumeexclusionoptions.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagevolumeexclusionoptions.go new file mode 100644 index 00000000000..f8a523a289d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inmagevolumeexclusionoptions.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InMageVolumeExclusionOptions struct { + OnlyExcludeIfSingleVolume *string `json:"onlyExcludeIfSingleVolume,omitempty"` + VolumeLabel *string `json:"volumeLabel,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_innerhealtherror.go new file mode 100644 index 00000000000..dc06e717b80 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationprotecteditems + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inputendpoint.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inputendpoint.go new file mode 100644 index 00000000000..a0e3fd45e70 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_inputendpoint.go @@ -0,0 +1,11 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InputEndpoint struct { + EndpointName *string `json:"endpointName,omitempty"` + PrivatePort *int64 `json:"privatePort,omitempty"` + Protocol *string `json:"protocol,omitempty"` + PublicPort *int64 `json:"publicPort,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_ipconfigdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_ipconfigdetails.go new file mode 100644 index 00000000000..74ce87533d6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_ipconfigdetails.go @@ -0,0 +1,22 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigDetails struct { + IPAddressType *string `json:"ipAddressType,omitempty"` + IsPrimary *bool `json:"isPrimary,omitempty"` + IsSeletedForFailover *bool `json:"isSeletedForFailover,omitempty"` + Name *string `json:"name,omitempty"` + RecoveryIPAddressType *string `json:"recoveryIPAddressType,omitempty"` + RecoveryLBBackendAddressPoolIds *[]string `json:"recoveryLBBackendAddressPoolIds,omitempty"` + RecoveryPublicIPAddressId *string `json:"recoveryPublicIPAddressId,omitempty"` + RecoveryStaticIPAddress *string `json:"recoveryStaticIPAddress,omitempty"` + RecoverySubnetName *string `json:"recoverySubnetName,omitempty"` + StaticIPAddress *string `json:"staticIPAddress,omitempty"` + SubnetName *string `json:"subnetName,omitempty"` + TfoLBBackendAddressPoolIds *[]string `json:"tfoLBBackendAddressPoolIds,omitempty"` + TfoPublicIPAddressId *string `json:"tfoPublicIPAddressId,omitempty"` + TfoStaticIPAddress *string `json:"tfoStaticIPAddress,omitempty"` + TfoSubnetName *string `json:"tfoSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_ipconfiginputdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_ipconfiginputdetails.go new file mode 100644 index 00000000000..de0609e9a0d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_ipconfiginputdetails.go @@ -0,0 +1,18 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigInputDetails struct { + IPConfigName *string `json:"ipConfigName,omitempty"` + IsPrimary *bool `json:"isPrimary,omitempty"` + IsSeletedForFailover *bool `json:"isSeletedForFailover,omitempty"` + RecoveryLBBackendAddressPoolIds *[]string `json:"recoveryLBBackendAddressPoolIds,omitempty"` + RecoveryPublicIPAddressId *string `json:"recoveryPublicIPAddressId,omitempty"` + RecoveryStaticIPAddress *string `json:"recoveryStaticIPAddress,omitempty"` + RecoverySubnetName *string `json:"recoverySubnetName,omitempty"` + TfoLBBackendAddressPoolIds *[]string `json:"tfoLBBackendAddressPoolIds,omitempty"` + TfoPublicIPAddressId *string `json:"tfoPublicIPAddressId,omitempty"` + TfoStaticIPAddress *string `json:"tfoStaticIPAddress,omitempty"` + TfoSubnetName *string `json:"tfoSubnetName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_keyencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_keyencryptionkeyinfo.go new file mode 100644 index 00000000000..b0d163a1195 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_keyencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyEncryptionKeyInfo struct { + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_osdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_osdetails.go new file mode 100644 index 00000000000..141a3f39061 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_osdetails.go @@ -0,0 +1,14 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSDetails struct { + OSMajorVersion *string `json:"oSMajorVersion,omitempty"` + OSMinorVersion *string `json:"oSMinorVersion,omitempty"` + OSVersion *string `json:"oSVersion,omitempty"` + OsEdition *string `json:"osEdition,omitempty"` + OsType *string `json:"osType,omitempty"` + ProductType *string `json:"productType,omitempty"` + UserSelectedOSName *string `json:"userSelectedOSName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_osdiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_osdiskdetails.go new file mode 100644 index 00000000000..9686e06d452 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_osdiskdetails.go @@ -0,0 +1,10 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSDiskDetails struct { + OsType *string `json:"osType,omitempty"` + OsVhdId *string `json:"osVhdId,omitempty"` + VhdName *string `json:"vhdName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_osupgradesupportedversions.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_osupgradesupportedversions.go new file mode 100644 index 00000000000..c67f7c6cdc9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_osupgradesupportedversions.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSUpgradeSupportedVersions struct { + SupportedSourceOsVersion *string `json:"supportedSourceOsVersion,omitempty"` + SupportedTargetOsVersions *[]string `json:"supportedTargetOsVersions,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_plannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_plannedfailoverinput.go new file mode 100644 index 00000000000..ccf7d67c6ad --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_plannedfailoverinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlannedFailoverInput struct { + Properties *PlannedFailoverInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_plannedfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_plannedfailoverinputproperties.go new file mode 100644 index 00000000000..24a70ce3078 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_plannedfailoverinputproperties.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +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 PlannedFailoverInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + ProviderSpecificDetails PlannedFailoverProviderSpecificFailoverInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &PlannedFailoverInputProperties{} + +func (s *PlannedFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling PlannedFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalPlannedFailoverProviderSpecificFailoverInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'PlannedFailoverInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_plannedfailoverproviderspecificfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_plannedfailoverproviderspecificfailoverinput.go new file mode 100644 index 00000000000..383a54e920c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_plannedfailoverproviderspecificfailoverinput.go @@ -0,0 +1,91 @@ +package replicationprotecteditems + +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 PlannedFailoverProviderSpecificFailoverInput interface { + PlannedFailoverProviderSpecificFailoverInput() BasePlannedFailoverProviderSpecificFailoverInputImpl +} + +var _ PlannedFailoverProviderSpecificFailoverInput = BasePlannedFailoverProviderSpecificFailoverInputImpl{} + +type BasePlannedFailoverProviderSpecificFailoverInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BasePlannedFailoverProviderSpecificFailoverInputImpl) PlannedFailoverProviderSpecificFailoverInput() BasePlannedFailoverProviderSpecificFailoverInputImpl { + return s +} + +var _ PlannedFailoverProviderSpecificFailoverInput = RawPlannedFailoverProviderSpecificFailoverInputImpl{} + +// RawPlannedFailoverProviderSpecificFailoverInputImpl 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 RawPlannedFailoverProviderSpecificFailoverInputImpl struct { + plannedFailoverProviderSpecificFailoverInput BasePlannedFailoverProviderSpecificFailoverInputImpl + Type string + Values map[string]interface{} +} + +func (s RawPlannedFailoverProviderSpecificFailoverInputImpl) PlannedFailoverProviderSpecificFailoverInput() BasePlannedFailoverProviderSpecificFailoverInputImpl { + return s.plannedFailoverProviderSpecificFailoverInput +} + +func UnmarshalPlannedFailoverProviderSpecificFailoverInputImplementation(input []byte) (PlannedFailoverProviderSpecificFailoverInput, 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 PlannedFailoverProviderSpecificFailoverInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "HyperVReplicaAzureFailback") { + var out HyperVReplicaAzureFailbackProviderInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureFailbackProviderInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzurePlannedFailoverProviderInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzurePlannedFailoverProviderInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackPlannedFailoverProviderInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackPlannedFailoverProviderInput: %+v", err) + } + return out, nil + } + + var parent BasePlannedFailoverProviderSpecificFailoverInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BasePlannedFailoverProviderSpecificFailoverInputImpl: %+v", err) + } + + return RawPlannedFailoverProviderSpecificFailoverInputImpl{ + plannedFailoverProviderSpecificFailoverInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_removedisksinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_removedisksinput.go new file mode 100644 index 00000000000..bfb58b0e932 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_removedisksinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoveDisksInput struct { + Properties *RemoveDisksInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_removedisksinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_removedisksinputproperties.go new file mode 100644 index 00000000000..7f07f3f0bf7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_removedisksinputproperties.go @@ -0,0 +1,33 @@ +package replicationprotecteditems + +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 RemoveDisksInputProperties struct { + ProviderSpecificDetails RemoveDisksProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &RemoveDisksInputProperties{} + +func (s *RemoveDisksInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RemoveDisksInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalRemoveDisksProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'RemoveDisksInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_removedisksproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_removedisksproviderspecificinput.go new file mode 100644 index 00000000000..ee7ec283473 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_removedisksproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 RemoveDisksProviderSpecificInput interface { + RemoveDisksProviderSpecificInput() BaseRemoveDisksProviderSpecificInputImpl +} + +var _ RemoveDisksProviderSpecificInput = BaseRemoveDisksProviderSpecificInputImpl{} + +type BaseRemoveDisksProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseRemoveDisksProviderSpecificInputImpl) RemoveDisksProviderSpecificInput() BaseRemoveDisksProviderSpecificInputImpl { + return s +} + +var _ RemoveDisksProviderSpecificInput = RawRemoveDisksProviderSpecificInputImpl{} + +// RawRemoveDisksProviderSpecificInputImpl 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 RawRemoveDisksProviderSpecificInputImpl struct { + removeDisksProviderSpecificInput BaseRemoveDisksProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawRemoveDisksProviderSpecificInputImpl) RemoveDisksProviderSpecificInput() BaseRemoveDisksProviderSpecificInputImpl { + return s.removeDisksProviderSpecificInput +} + +func UnmarshalRemoveDisksProviderSpecificInputImplementation(input []byte) (RemoveDisksProviderSpecificInput, 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 RemoveDisksProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2ARemoveDisksInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ARemoveDisksInput: %+v", err) + } + return out, nil + } + + var parent BaseRemoveDisksProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRemoveDisksProviderSpecificInputImpl: %+v", err) + } + + return RawRemoveDisksProviderSpecificInputImpl{ + removeDisksProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_replicationprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_replicationprotecteditem.go new file mode 100644 index 00000000000..8c86ba791a1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_replicationprotecteditem.go @@ -0,0 +1,12 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectedItem struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReplicationProtectedItemProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_replicationprotecteditemproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_replicationprotecteditemproperties.go new file mode 100644 index 00000000000..db913d4e503 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_replicationprotecteditemproperties.go @@ -0,0 +1,153 @@ +package replicationprotecteditems + +import ( + "encoding/json" + "fmt" + "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 ReplicationProtectedItemProperties struct { + ActiveLocation *string `json:"activeLocation,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + EventCorrelationId *string `json:"eventCorrelationId,omitempty"` + FailoverHealth *string `json:"failoverHealth,omitempty"` + FailoverRecoveryPointId *string `json:"failoverRecoveryPointId,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + LastSuccessfulFailoverTime *string `json:"lastSuccessfulFailoverTime,omitempty"` + LastSuccessfulTestFailoverTime *string `json:"lastSuccessfulTestFailoverTime,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryFabricProvider *string `json:"primaryFabricProvider,omitempty"` + PrimaryProtectionContainerFriendlyName *string `json:"primaryProtectionContainerFriendlyName,omitempty"` + ProtectableItemId *string `json:"protectableItemId,omitempty"` + ProtectedItemType *string `json:"protectedItemType,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + ProtectionStateDescription *string `json:"protectionStateDescription,omitempty"` + ProviderSpecificDetails ReplicationProviderSpecificSettings `json:"providerSpecificDetails"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricId *string `json:"recoveryFabricId,omitempty"` + RecoveryProtectionContainerFriendlyName *string `json:"recoveryProtectionContainerFriendlyName,omitempty"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationHealth *string `json:"replicationHealth,omitempty"` + SwitchProviderState *string `json:"switchProviderState,omitempty"` + SwitchProviderStateDescription *string `json:"switchProviderStateDescription,omitempty"` + TestFailoverState *string `json:"testFailoverState,omitempty"` + TestFailoverStateDescription *string `json:"testFailoverStateDescription,omitempty"` +} + +func (o *ReplicationProtectedItemProperties) GetLastSuccessfulFailoverTimeAsTime() (*time.Time, error) { + if o.LastSuccessfulFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastSuccessfulFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationProtectedItemProperties) SetLastSuccessfulFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastSuccessfulFailoverTime = &formatted +} + +func (o *ReplicationProtectedItemProperties) GetLastSuccessfulTestFailoverTimeAsTime() (*time.Time, error) { + if o.LastSuccessfulTestFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastSuccessfulTestFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationProtectedItemProperties) SetLastSuccessfulTestFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastSuccessfulTestFailoverTime = &formatted +} + +var _ json.Unmarshaler = &ReplicationProtectedItemProperties{} + +func (s *ReplicationProtectedItemProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ActiveLocation *string `json:"activeLocation,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + EventCorrelationId *string `json:"eventCorrelationId,omitempty"` + FailoverHealth *string `json:"failoverHealth,omitempty"` + FailoverRecoveryPointId *string `json:"failoverRecoveryPointId,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + LastSuccessfulFailoverTime *string `json:"lastSuccessfulFailoverTime,omitempty"` + LastSuccessfulTestFailoverTime *string `json:"lastSuccessfulTestFailoverTime,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryFabricProvider *string `json:"primaryFabricProvider,omitempty"` + PrimaryProtectionContainerFriendlyName *string `json:"primaryProtectionContainerFriendlyName,omitempty"` + ProtectableItemId *string `json:"protectableItemId,omitempty"` + ProtectedItemType *string `json:"protectedItemType,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + ProtectionStateDescription *string `json:"protectionStateDescription,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricId *string `json:"recoveryFabricId,omitempty"` + RecoveryProtectionContainerFriendlyName *string `json:"recoveryProtectionContainerFriendlyName,omitempty"` + RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"` + ReplicationHealth *string `json:"replicationHealth,omitempty"` + SwitchProviderState *string `json:"switchProviderState,omitempty"` + SwitchProviderStateDescription *string `json:"switchProviderStateDescription,omitempty"` + TestFailoverState *string `json:"testFailoverState,omitempty"` + TestFailoverStateDescription *string `json:"testFailoverStateDescription,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ActiveLocation = decoded.ActiveLocation + s.AllowedOperations = decoded.AllowedOperations + s.CurrentScenario = decoded.CurrentScenario + s.EventCorrelationId = decoded.EventCorrelationId + s.FailoverHealth = decoded.FailoverHealth + s.FailoverRecoveryPointId = decoded.FailoverRecoveryPointId + s.FriendlyName = decoded.FriendlyName + s.HealthErrors = decoded.HealthErrors + s.LastSuccessfulFailoverTime = decoded.LastSuccessfulFailoverTime + s.LastSuccessfulTestFailoverTime = decoded.LastSuccessfulTestFailoverTime + s.PolicyFriendlyName = decoded.PolicyFriendlyName + s.PolicyId = decoded.PolicyId + s.PrimaryFabricFriendlyName = decoded.PrimaryFabricFriendlyName + s.PrimaryFabricProvider = decoded.PrimaryFabricProvider + s.PrimaryProtectionContainerFriendlyName = decoded.PrimaryProtectionContainerFriendlyName + s.ProtectableItemId = decoded.ProtectableItemId + s.ProtectedItemType = decoded.ProtectedItemType + s.ProtectionState = decoded.ProtectionState + s.ProtectionStateDescription = decoded.ProtectionStateDescription + s.RecoveryContainerId = decoded.RecoveryContainerId + s.RecoveryFabricFriendlyName = decoded.RecoveryFabricFriendlyName + s.RecoveryFabricId = decoded.RecoveryFabricId + s.RecoveryProtectionContainerFriendlyName = decoded.RecoveryProtectionContainerFriendlyName + s.RecoveryServicesProviderId = decoded.RecoveryServicesProviderId + s.ReplicationHealth = decoded.ReplicationHealth + s.SwitchProviderState = decoded.SwitchProviderState + s.SwitchProviderStateDescription = decoded.SwitchProviderStateDescription + s.TestFailoverState = decoded.TestFailoverState + s.TestFailoverStateDescription = decoded.TestFailoverStateDescription + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ReplicationProtectedItemProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalReplicationProviderSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ReplicationProtectedItemProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_replicationproviderspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_replicationproviderspecificsettings.go new file mode 100644 index 00000000000..9c657e69eb9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_replicationproviderspecificsettings.go @@ -0,0 +1,147 @@ +package replicationprotecteditems + +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 ReplicationProviderSpecificSettings interface { + ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl +} + +var _ ReplicationProviderSpecificSettings = BaseReplicationProviderSpecificSettingsImpl{} + +type BaseReplicationProviderSpecificSettingsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseReplicationProviderSpecificSettingsImpl) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return s +} + +var _ ReplicationProviderSpecificSettings = RawReplicationProviderSpecificSettingsImpl{} + +// RawReplicationProviderSpecificSettingsImpl 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 RawReplicationProviderSpecificSettingsImpl struct { + replicationProviderSpecificSettings BaseReplicationProviderSpecificSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawReplicationProviderSpecificSettingsImpl) ReplicationProviderSpecificSettings() BaseReplicationProviderSpecificSettingsImpl { + return s.replicationProviderSpecificSettings +} + +func UnmarshalReplicationProviderSpecificSettingsImplementation(input []byte) (ReplicationProviderSpecificSettings, 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 ReplicationProviderSpecificSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2A") { + var out A2AReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaBaseReplicationDetails") { + var out HyperVReplicaBaseReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBaseReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012R2") { + var out HyperVReplicaBlueReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaBlueReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplica2012") { + var out HyperVReplicaReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2ReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2ReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmReplicationDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageReplicationDetails: %+v", err) + } + return out, nil + } + + var parent BaseReplicationProviderSpecificSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseReplicationProviderSpecificSettingsImpl: %+v", err) + } + + return RawReplicationProviderSpecificSettingsImpl{ + replicationProviderSpecificSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_resolvehealtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_resolvehealtherror.go new file mode 100644 index 00000000000..0fc7181b7ab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_resolvehealtherror.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResolveHealthError struct { + HealthErrorId *string `json:"healthErrorId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_resolvehealthinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_resolvehealthinput.go new file mode 100644 index 00000000000..57ce7884f4b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_resolvehealthinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResolveHealthInput struct { + Properties *ResolveHealthInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_resolvehealthinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_resolvehealthinputproperties.go new file mode 100644 index 00000000000..735fbf2ee53 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_resolvehealthinputproperties.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResolveHealthInputProperties struct { + HealthErrors *[]ResolveHealthError `json:"healthErrors,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_reversereplicationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_reversereplicationinput.go new file mode 100644 index 00000000000..dcd65ebb176 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_reversereplicationinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReverseReplicationInput struct { + Properties *ReverseReplicationInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_reversereplicationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_reversereplicationinputproperties.go new file mode 100644 index 00000000000..46e9f290241 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_reversereplicationinputproperties.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +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 ReverseReplicationInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + ProviderSpecificDetails ReverseReplicationProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ReverseReplicationInputProperties{} + +func (s *ReverseReplicationInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ReverseReplicationInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalReverseReplicationProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ReverseReplicationInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_reversereplicationproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_reversereplicationproviderspecificinput.go new file mode 100644 index 00000000000..99bb04d2d4a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_reversereplicationproviderspecificinput.go @@ -0,0 +1,115 @@ +package replicationprotecteditems + +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 ReverseReplicationProviderSpecificInput interface { + ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl +} + +var _ ReverseReplicationProviderSpecificInput = BaseReverseReplicationProviderSpecificInputImpl{} + +type BaseReverseReplicationProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseReverseReplicationProviderSpecificInputImpl) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return s +} + +var _ ReverseReplicationProviderSpecificInput = RawReverseReplicationProviderSpecificInputImpl{} + +// RawReverseReplicationProviderSpecificInputImpl 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 RawReverseReplicationProviderSpecificInputImpl struct { + reverseReplicationProviderSpecificInput BaseReverseReplicationProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawReverseReplicationProviderSpecificInputImpl) ReverseReplicationProviderSpecificInput() BaseReverseReplicationProviderSpecificInputImpl { + return s.reverseReplicationProviderSpecificInput +} + +func UnmarshalReverseReplicationProviderSpecificInputImplementation(input []byte) (ReverseReplicationProviderSpecificInput, 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 ReverseReplicationProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2ReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2ReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out InMageRcmFailbackReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmFailbackReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmReprotectInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageReprotectInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageReprotectInput: %+v", err) + } + return out, nil + } + + var parent BaseReverseReplicationProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseReverseReplicationProviderSpecificInputImpl: %+v", err) + } + + return RawReverseReplicationProviderSpecificInputImpl{ + reverseReplicationProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_securityprofileproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_securityprofileproperties.go new file mode 100644 index 00000000000..d51860996d8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_securityprofileproperties.go @@ -0,0 +1,12 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityProfileProperties struct { + TargetVMConfidentialEncryption *SecurityConfiguration `json:"targetVmConfidentialEncryption,omitempty"` + TargetVMMonitoring *SecurityConfiguration `json:"targetVmMonitoring,omitempty"` + TargetVMSecureBoot *SecurityConfiguration `json:"targetVmSecureBoot,omitempty"` + TargetVMSecurityType *SecurityType `json:"targetVmSecurityType,omitempty"` + TargetVMTpm *SecurityConfiguration `json:"targetVmTpm,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_switchproviderinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_switchproviderinput.go new file mode 100644 index 00000000000..701b7dcfb6f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_switchproviderinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchProviderInput struct { + Properties *SwitchProviderInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_switchproviderinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_switchproviderinputproperties.go new file mode 100644 index 00000000000..6189d20b837 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_switchproviderinputproperties.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +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 SwitchProviderInputProperties struct { + ProviderSpecificDetails SwitchProviderProviderSpecificInput `json:"providerSpecificDetails"` + TargetInstanceType *string `json:"targetInstanceType,omitempty"` +} + +var _ json.Unmarshaler = &SwitchProviderInputProperties{} + +func (s *SwitchProviderInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + TargetInstanceType *string `json:"targetInstanceType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.TargetInstanceType = decoded.TargetInstanceType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SwitchProviderInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalSwitchProviderProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'SwitchProviderInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_switchproviderproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_switchproviderproviderspecificinput.go new file mode 100644 index 00000000000..a30916cc168 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_switchproviderproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 SwitchProviderProviderSpecificInput interface { + SwitchProviderProviderSpecificInput() BaseSwitchProviderProviderSpecificInputImpl +} + +var _ SwitchProviderProviderSpecificInput = BaseSwitchProviderProviderSpecificInputImpl{} + +type BaseSwitchProviderProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseSwitchProviderProviderSpecificInputImpl) SwitchProviderProviderSpecificInput() BaseSwitchProviderProviderSpecificInputImpl { + return s +} + +var _ SwitchProviderProviderSpecificInput = RawSwitchProviderProviderSpecificInputImpl{} + +// RawSwitchProviderProviderSpecificInputImpl 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 RawSwitchProviderProviderSpecificInputImpl struct { + switchProviderProviderSpecificInput BaseSwitchProviderProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawSwitchProviderProviderSpecificInputImpl) SwitchProviderProviderSpecificInput() BaseSwitchProviderProviderSpecificInputImpl { + return s.switchProviderProviderSpecificInput +} + +func UnmarshalSwitchProviderProviderSpecificInputImplementation(input []byte) (SwitchProviderProviderSpecificInput, 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 SwitchProviderProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2SwitchProviderProviderInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2SwitchProviderProviderInput: %+v", err) + } + return out, nil + } + + var parent BaseSwitchProviderProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSwitchProviderProviderSpecificInputImpl: %+v", err) + } + + return RawSwitchProviderProviderSpecificInputImpl{ + switchProviderProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailovercleanupinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailovercleanupinput.go new file mode 100644 index 00000000000..29c6eb3256b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailovercleanupinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverCleanupInput struct { + Properties TestFailoverCleanupInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailovercleanupinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailovercleanupinputproperties.go new file mode 100644 index 00000000000..9699a278467 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailovercleanupinputproperties.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverCleanupInputProperties struct { + Comments *string `json:"comments,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailoverinput.go new file mode 100644 index 00000000000..88eb28a5898 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailoverinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverInput struct { + Properties TestFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailoverinputproperties.go new file mode 100644 index 00000000000..e49d86c1c45 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailoverinputproperties.go @@ -0,0 +1,48 @@ +package replicationprotecteditems + +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 TestFailoverInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + NetworkId *string `json:"networkId,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + ProviderSpecificDetails TestFailoverProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &TestFailoverInputProperties{} + +func (s *TestFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + NetworkId *string `json:"networkId,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.NetworkId = decoded.NetworkId + s.NetworkType = decoded.NetworkType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling TestFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalTestFailoverProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'TestFailoverInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailoverproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailoverproviderspecificinput.go new file mode 100644 index 00000000000..3ea707b3cc2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_testfailoverproviderspecificinput.go @@ -0,0 +1,107 @@ +package replicationprotecteditems + +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 TestFailoverProviderSpecificInput interface { + TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl +} + +var _ TestFailoverProviderSpecificInput = BaseTestFailoverProviderSpecificInputImpl{} + +type BaseTestFailoverProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseTestFailoverProviderSpecificInputImpl) TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl { + return s +} + +var _ TestFailoverProviderSpecificInput = RawTestFailoverProviderSpecificInputImpl{} + +// RawTestFailoverProviderSpecificInputImpl 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 RawTestFailoverProviderSpecificInputImpl struct { + testFailoverProviderSpecificInput BaseTestFailoverProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawTestFailoverProviderSpecificInputImpl) TestFailoverProviderSpecificInput() BaseTestFailoverProviderSpecificInputImpl { + return s.testFailoverProviderSpecificInput +} + +func UnmarshalTestFailoverProviderSpecificInputImplementation(input []byte) (TestFailoverProviderSpecificInput, 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 TestFailoverProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2ATestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ATestFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureTestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureTestFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2TestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2TestFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmTestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmTestFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageTestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageTestFailoverInput: %+v", err) + } + return out, nil + } + + var parent BaseTestFailoverProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseTestFailoverProviderSpecificInputImpl: %+v", err) + } + + return RawTestFailoverProviderSpecificInputImpl{ + testFailoverProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_unplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_unplannedfailoverinput.go new file mode 100644 index 00000000000..12ae4f94f48 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_unplannedfailoverinput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnplannedFailoverInput struct { + Properties UnplannedFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_unplannedfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_unplannedfailoverinputproperties.go new file mode 100644 index 00000000000..48640dc991d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_unplannedfailoverinputproperties.go @@ -0,0 +1,45 @@ +package replicationprotecteditems + +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 UnplannedFailoverInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + ProviderSpecificDetails UnplannedFailoverProviderSpecificInput `json:"providerSpecificDetails"` + SourceSiteOperations *string `json:"sourceSiteOperations,omitempty"` +} + +var _ json.Unmarshaler = &UnplannedFailoverInputProperties{} + +func (s *UnplannedFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + SourceSiteOperations *string `json:"sourceSiteOperations,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.SourceSiteOperations = decoded.SourceSiteOperations + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UnplannedFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalUnplannedFailoverProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'UnplannedFailoverInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_unplannedfailoverproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_unplannedfailoverproviderspecificinput.go new file mode 100644 index 00000000000..2d97495c032 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_unplannedfailoverproviderspecificinput.go @@ -0,0 +1,107 @@ +package replicationprotecteditems + +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 UnplannedFailoverProviderSpecificInput interface { + UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl +} + +var _ UnplannedFailoverProviderSpecificInput = BaseUnplannedFailoverProviderSpecificInputImpl{} + +type BaseUnplannedFailoverProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseUnplannedFailoverProviderSpecificInputImpl) UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl { + return s +} + +var _ UnplannedFailoverProviderSpecificInput = RawUnplannedFailoverProviderSpecificInputImpl{} + +// RawUnplannedFailoverProviderSpecificInputImpl 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 RawUnplannedFailoverProviderSpecificInputImpl struct { + unplannedFailoverProviderSpecificInput BaseUnplannedFailoverProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawUnplannedFailoverProviderSpecificInputImpl) UnplannedFailoverProviderSpecificInput() BaseUnplannedFailoverProviderSpecificInputImpl { + return s.unplannedFailoverProviderSpecificInput +} + +func UnmarshalUnplannedFailoverProviderSpecificInputImplementation(input []byte) (UnplannedFailoverProviderSpecificInput, 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 UnplannedFailoverProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AUnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AUnplannedFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureUnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureUnplannedFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2UnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2UnplannedFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmUnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmUnplannedFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out InMageUnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageUnplannedFailoverInput: %+v", err) + } + return out, nil + } + + var parent BaseUnplannedFailoverProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseUnplannedFailoverProviderSpecificInputImpl: %+v", err) + } + + return RawUnplannedFailoverProviderSpecificInputImpl{ + unplannedFailoverProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminput.go new file mode 100644 index 00000000000..8bb8dbd243c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateApplianceForReplicationProtectedItemInput struct { + Properties UpdateApplianceForReplicationProtectedItemInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminputproperties.go new file mode 100644 index 00000000000..02ecc50d9ff --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updateapplianceforreplicationprotectediteminputproperties.go @@ -0,0 +1,42 @@ +package replicationprotecteditems + +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 UpdateApplianceForReplicationProtectedItemInputProperties struct { + ProviderSpecificDetails UpdateApplianceForReplicationProtectedItemProviderSpecificInput `json:"providerSpecificDetails"` + TargetApplianceId string `json:"targetApplianceId"` +} + +var _ json.Unmarshaler = &UpdateApplianceForReplicationProtectedItemInputProperties{} + +func (s *UpdateApplianceForReplicationProtectedItemInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + TargetApplianceId string `json:"targetApplianceId"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.TargetApplianceId = decoded.TargetApplianceId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateApplianceForReplicationProtectedItemInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalUpdateApplianceForReplicationProtectedItemProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'UpdateApplianceForReplicationProtectedItemInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updateapplianceforreplicationprotecteditemproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updateapplianceforreplicationprotecteditemproviderspecificinput.go new file mode 100644 index 00000000000..e6f03eb7aaa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updateapplianceforreplicationprotecteditemproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotecteditems + +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 UpdateApplianceForReplicationProtectedItemProviderSpecificInput interface { + UpdateApplianceForReplicationProtectedItemProviderSpecificInput() BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl +} + +var _ UpdateApplianceForReplicationProtectedItemProviderSpecificInput = BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl{} + +type BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl) UpdateApplianceForReplicationProtectedItemProviderSpecificInput() BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl { + return s +} + +var _ UpdateApplianceForReplicationProtectedItemProviderSpecificInput = RawUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl{} + +// RawUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl 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 RawUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl struct { + updateApplianceForReplicationProtectedItemProviderSpecificInput BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl) UpdateApplianceForReplicationProtectedItemProviderSpecificInput() BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl { + return s.updateApplianceForReplicationProtectedItemProviderSpecificInput +} + +func UnmarshalUpdateApplianceForReplicationProtectedItemProviderSpecificInputImplementation(input []byte) (UpdateApplianceForReplicationProtectedItemProviderSpecificInput, 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 UpdateApplianceForReplicationProtectedItemProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmUpdateApplianceForReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmUpdateApplianceForReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + var parent BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl: %+v", err) + } + + return RawUpdateApplianceForReplicationProtectedItemProviderSpecificInputImpl{ + updateApplianceForReplicationProtectedItemProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatediskinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatediskinput.go new file mode 100644 index 00000000000..bf04404073c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatediskinput.go @@ -0,0 +1,12 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateDiskInput struct { + DiskId string `json:"diskId"` + DiskSizeInGB *int64 `json:"diskSizeInGB,omitempty"` + Iops *int64 `json:"iops,omitempty"` + TargetDiskName *string `json:"targetDiskName,omitempty"` + ThroughputInMbps *int64 `json:"throughputInMbps,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatemobilityservicerequest.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatemobilityservicerequest.go new file mode 100644 index 00000000000..88df4c561c1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatemobilityservicerequest.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMobilityServiceRequest struct { + Properties *UpdateMobilityServiceRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatemobilityservicerequestproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatemobilityservicerequestproperties.go new file mode 100644 index 00000000000..bc5afdc6871 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatemobilityservicerequestproperties.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMobilityServiceRequestProperties struct { + RunAsAccountId *string `json:"runAsAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatereplicationprotectediteminput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatereplicationprotectediteminput.go new file mode 100644 index 00000000000..6a33ddab87b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatereplicationprotectediteminput.go @@ -0,0 +1,8 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateReplicationProtectedItemInput struct { + Properties *UpdateReplicationProtectedItemInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatereplicationprotectediteminputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatereplicationprotectediteminputproperties.go new file mode 100644 index 00000000000..1bcbcbfe84e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatereplicationprotectediteminputproperties.go @@ -0,0 +1,66 @@ +package replicationprotecteditems + +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 UpdateReplicationProtectedItemInputProperties struct { + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + ProviderSpecificDetails UpdateReplicationProtectedItemProviderInput `json:"providerSpecificDetails"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + SelectedRecoveryAzureNetworkId *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + SelectedSourceNicId *string `json:"selectedSourceNicId,omitempty"` + SelectedTfoAzureNetworkId *string `json:"selectedTfoAzureNetworkId,omitempty"` + VMNics *[]VMNicInputDetails `json:"vmNics,omitempty"` +} + +var _ json.Unmarshaler = &UpdateReplicationProtectedItemInputProperties{} + +func (s *UpdateReplicationProtectedItemInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + EnableRdpOnTargetOption *string `json:"enableRdpOnTargetOption,omitempty"` + LicenseType *LicenseType `json:"licenseType,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + SelectedRecoveryAzureNetworkId *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + SelectedSourceNicId *string `json:"selectedSourceNicId,omitempty"` + SelectedTfoAzureNetworkId *string `json:"selectedTfoAzureNetworkId,omitempty"` + VMNics *[]VMNicInputDetails `json:"vmNics,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.EnableRdpOnTargetOption = decoded.EnableRdpOnTargetOption + s.LicenseType = decoded.LicenseType + s.RecoveryAvailabilitySetId = decoded.RecoveryAvailabilitySetId + s.RecoveryAzureVMName = decoded.RecoveryAzureVMName + s.RecoveryAzureVMSize = decoded.RecoveryAzureVMSize + s.SelectedRecoveryAzureNetworkId = decoded.SelectedRecoveryAzureNetworkId + s.SelectedSourceNicId = decoded.SelectedSourceNicId + s.SelectedTfoAzureNetworkId = decoded.SelectedTfoAzureNetworkId + s.VMNics = decoded.VMNics + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateReplicationProtectedItemInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalUpdateReplicationProtectedItemProviderInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'UpdateReplicationProtectedItemInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatereplicationprotecteditemproviderinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatereplicationprotecteditemproviderinput.go new file mode 100644 index 00000000000..de39df0cec7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_updatereplicationprotecteditemproviderinput.go @@ -0,0 +1,99 @@ +package replicationprotecteditems + +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 UpdateReplicationProtectedItemProviderInput interface { + UpdateReplicationProtectedItemProviderInput() BaseUpdateReplicationProtectedItemProviderInputImpl +} + +var _ UpdateReplicationProtectedItemProviderInput = BaseUpdateReplicationProtectedItemProviderInputImpl{} + +type BaseUpdateReplicationProtectedItemProviderInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseUpdateReplicationProtectedItemProviderInputImpl) UpdateReplicationProtectedItemProviderInput() BaseUpdateReplicationProtectedItemProviderInputImpl { + return s +} + +var _ UpdateReplicationProtectedItemProviderInput = RawUpdateReplicationProtectedItemProviderInputImpl{} + +// RawUpdateReplicationProtectedItemProviderInputImpl 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 RawUpdateReplicationProtectedItemProviderInputImpl struct { + updateReplicationProtectedItemProviderInput BaseUpdateReplicationProtectedItemProviderInputImpl + Type string + Values map[string]interface{} +} + +func (s RawUpdateReplicationProtectedItemProviderInputImpl) UpdateReplicationProtectedItemProviderInput() BaseUpdateReplicationProtectedItemProviderInputImpl { + return s.updateReplicationProtectedItemProviderInput +} + +func UnmarshalUpdateReplicationProtectedItemProviderInputImplementation(input []byte) (UpdateReplicationProtectedItemProviderInput, 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 UpdateReplicationProtectedItemProviderInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AUpdateReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AUpdateReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out HyperVReplicaAzureUpdateReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HyperVReplicaAzureUpdateReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out InMageAzureV2UpdateReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageAzureV2UpdateReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmUpdateReplicationProtectedItemInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmUpdateReplicationProtectedItemInput: %+v", err) + } + return out, nil + } + + var parent BaseUpdateReplicationProtectedItemProviderInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseUpdateReplicationProtectedItemProviderInputImpl: %+v", err) + } + + return RawUpdateReplicationProtectedItemProviderInputImpl{ + updateReplicationProtectedItemProviderInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_usercreatedresourcetag.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_usercreatedresourcetag.go new file mode 100644 index 00000000000..675f4368cc0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_usercreatedresourcetag.go @@ -0,0 +1,9 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserCreatedResourceTag struct { + TagName *string `json:"tagName,omitempty"` + TagValue *string `json:"tagValue,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_vmnicdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_vmnicdetails.go new file mode 100644 index 00000000000..aa704f28341 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_vmnicdetails.go @@ -0,0 +1,26 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMNicDetails struct { + EnableAcceleratedNetworkingOnRecovery *bool `json:"enableAcceleratedNetworkingOnRecovery,omitempty"` + EnableAcceleratedNetworkingOnTfo *bool `json:"enableAcceleratedNetworkingOnTfo,omitempty"` + IPConfigs *[]IPConfigDetails `json:"ipConfigs,omitempty"` + NicId *string `json:"nicId,omitempty"` + RecoveryNetworkSecurityGroupId *string `json:"recoveryNetworkSecurityGroupId,omitempty"` + RecoveryNicName *string `json:"recoveryNicName,omitempty"` + RecoveryNicResourceGroupName *string `json:"recoveryNicResourceGroupName,omitempty"` + RecoveryVMNetworkId *string `json:"recoveryVMNetworkId,omitempty"` + ReplicaNicId *string `json:"replicaNicId,omitempty"` + ReuseExistingNic *bool `json:"reuseExistingNic,omitempty"` + SelectionType *string `json:"selectionType,omitempty"` + SourceNicArmId *string `json:"sourceNicArmId,omitempty"` + TargetNicName *string `json:"targetNicName,omitempty"` + TfoNetworkSecurityGroupId *string `json:"tfoNetworkSecurityGroupId,omitempty"` + TfoRecoveryNicName *string `json:"tfoRecoveryNicName,omitempty"` + TfoRecoveryNicResourceGroupName *string `json:"tfoRecoveryNicResourceGroupName,omitempty"` + TfoReuseExistingNic *bool `json:"tfoReuseExistingNic,omitempty"` + TfoVMNetworkId *string `json:"tfoVMNetworkId,omitempty"` + VMNetworkName *string `json:"vMNetworkName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_vmnicinputdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_vmnicinputdetails.go new file mode 100644 index 00000000000..7c18c51a759 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/model_vmnicinputdetails.go @@ -0,0 +1,21 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMNicInputDetails struct { + EnableAcceleratedNetworkingOnRecovery *bool `json:"enableAcceleratedNetworkingOnRecovery,omitempty"` + EnableAcceleratedNetworkingOnTfo *bool `json:"enableAcceleratedNetworkingOnTfo,omitempty"` + IPConfigs *[]IPConfigInputDetails `json:"ipConfigs,omitempty"` + NicId *string `json:"nicId,omitempty"` + RecoveryNetworkSecurityGroupId *string `json:"recoveryNetworkSecurityGroupId,omitempty"` + RecoveryNicName *string `json:"recoveryNicName,omitempty"` + RecoveryNicResourceGroupName *string `json:"recoveryNicResourceGroupName,omitempty"` + ReuseExistingNic *bool `json:"reuseExistingNic,omitempty"` + SelectionType *string `json:"selectionType,omitempty"` + TargetNicName *string `json:"targetNicName,omitempty"` + TfoNetworkSecurityGroupId *string `json:"tfoNetworkSecurityGroupId,omitempty"` + TfoNicName *string `json:"tfoNicName,omitempty"` + TfoNicResourceGroupName *string `json:"tfoNicResourceGroupName,omitempty"` + TfoReuseExistingNic *bool `json:"tfoReuseExistingNic,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/predicates.go new file mode 100644 index 00000000000..533da5b6f5e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/predicates.go @@ -0,0 +1,32 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectedItemOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ReplicationProtectedItemOperationPredicate) Matches(input ReplicationProtectedItem) 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/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/version.go new file mode 100644 index 00000000000..1d232131f53 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotecteditems/version.go @@ -0,0 +1,10 @@ +package replicationprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationprotecteditems/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/README.md new file mode 100644 index 00000000000..e96f3b7f600 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/README.md @@ -0,0 +1,191 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters` Documentation + +The `replicationprotectionclusters` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters" +``` + + +### Client Initialization + +```go +client := replicationprotectionclusters.NewReplicationProtectionClustersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectionClustersClient.ApplyRecoveryPoint` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +payload := replicationprotectionclusters.ApplyClusterRecoveryPointInput{ + // ... +} + + +if err := client.ApplyRecoveryPointThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.Create` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +payload := replicationprotectionclusters.ReplicationProtectionCluster{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.FailoverCommit` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +if err := client.FailoverCommitThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.Get` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +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: `ReplicationProtectionClustersClient.List` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, replicationprotectionclusters.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationprotectionclusters.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.ListByReplicationProtectionContainers` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +// alternatively `client.ListByReplicationProtectionContainers(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectionContainersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.Purge` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +if err := client.PurgeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.RepairReplication` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +if err := client.RepairReplicationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.TestFailover` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +payload := replicationprotectionclusters.ClusterTestFailoverInput{ + // ... +} + + +if err := client.TestFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.TestFailoverCleanup` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +payload := replicationprotectionclusters.ClusterTestFailoverCleanupInput{ + // ... +} + + +if err := client.TestFailoverCleanupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionClustersClient.UnplannedFailover` + +```go +ctx := context.TODO() +id := replicationprotectionclusters.NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + +payload := replicationprotectionclusters.ClusterUnplannedFailoverInput{ + // ... +} + + +if err := client.UnplannedFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/client.go new file mode 100644 index 00000000000..0b827715b54 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/client.go @@ -0,0 +1,26 @@ +package replicationprotectionclusters + +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 ReplicationProtectionClustersClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectionClustersClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectionClustersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationprotectionclusters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectionClustersClient: %+v", err) + } + + return &ReplicationProtectionClustersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/constants.go new file mode 100644 index 00000000000..118ab2f7fb9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/constants.go @@ -0,0 +1,174 @@ +package replicationprotectionclusters + +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 AutoProtectionOfDataDisk string + +const ( + AutoProtectionOfDataDiskDisabled AutoProtectionOfDataDisk = "Disabled" + AutoProtectionOfDataDiskEnabled AutoProtectionOfDataDisk = "Enabled" +) + +func PossibleValuesForAutoProtectionOfDataDisk() []string { + return []string{ + string(AutoProtectionOfDataDiskDisabled), + string(AutoProtectionOfDataDiskEnabled), + } +} + +func (s *AutoProtectionOfDataDisk) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoProtectionOfDataDisk(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoProtectionOfDataDisk(input string) (*AutoProtectionOfDataDisk, error) { + vals := map[string]AutoProtectionOfDataDisk{ + "disabled": AutoProtectionOfDataDiskDisabled, + "enabled": AutoProtectionOfDataDiskEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoProtectionOfDataDisk(input) + return &out, nil +} + +type FailoverDirection string + +const ( + FailoverDirectionPrimaryToRecovery FailoverDirection = "PrimaryToRecovery" + FailoverDirectionRecoveryToPrimary FailoverDirection = "RecoveryToPrimary" +) + +func PossibleValuesForFailoverDirection() []string { + return []string{ + string(FailoverDirectionPrimaryToRecovery), + string(FailoverDirectionRecoveryToPrimary), + } +} + +func (s *FailoverDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailoverDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFailoverDirection(input string) (*FailoverDirection, error) { + vals := map[string]FailoverDirection{ + "primarytorecovery": FailoverDirectionPrimaryToRecovery, + "recoverytoprimary": FailoverDirectionRecoveryToPrimary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FailoverDirection(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type MultiVMGroupCreateOption string + +const ( + MultiVMGroupCreateOptionAutoCreated MultiVMGroupCreateOption = "AutoCreated" + MultiVMGroupCreateOptionUserSpecified MultiVMGroupCreateOption = "UserSpecified" +) + +func PossibleValuesForMultiVMGroupCreateOption() []string { + return []string{ + string(MultiVMGroupCreateOptionAutoCreated), + string(MultiVMGroupCreateOptionUserSpecified), + } +} + +func (s *MultiVMGroupCreateOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMultiVMGroupCreateOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMultiVMGroupCreateOption(input string) (*MultiVMGroupCreateOption, error) { + vals := map[string]MultiVMGroupCreateOption{ + "autocreated": MultiVMGroupCreateOptionAutoCreated, + "userspecified": MultiVMGroupCreateOptionUserSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MultiVMGroupCreateOption(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_replicationprotectioncluster.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_replicationprotectioncluster.go new file mode 100644 index 00000000000..2f390968800 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_replicationprotectioncluster.go @@ -0,0 +1,157 @@ +package replicationprotectionclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectionClusterId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionClusterId{} + +// ReplicationProtectionClusterId is a struct representing the Resource ID for a Replication Protection Cluster +type ReplicationProtectionClusterId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectionClusterName string +} + +// NewReplicationProtectionClusterID returns a new ReplicationProtectionClusterId struct +func NewReplicationProtectionClusterID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectionClusterName string) ReplicationProtectionClusterId { + return ReplicationProtectionClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectionClusterName: replicationProtectionClusterName, + } +} + +// ParseReplicationProtectionClusterID parses 'input' into a ReplicationProtectionClusterId +func ParseReplicationProtectionClusterID(input string) (*ReplicationProtectionClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionClusterIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionClusterId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionClusterIDInsensitively(input string) (*ReplicationProtectionClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionClusterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectionClusterName, ok = input.Parsed["replicationProtectionClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionClusterName", input) + } + + return nil +} + +// ValidateReplicationProtectionClusterID checks that 'input' can be parsed as a Replication Protection Cluster ID +func ValidateReplicationProtectionClusterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectionClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Cluster ID +func (id ReplicationProtectionClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectionClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectionClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Cluster ID +func (id ReplicationProtectionClusterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectionClusters", "replicationProtectionClusters", "replicationProtectionClusters"), + resourceids.UserSpecifiedSegment("replicationProtectionClusterName", "replicationProtectionClusterName"), + } +} + +// String returns a human-readable description of this Replication Protection Cluster ID +func (id ReplicationProtectionClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protection Cluster Name: %q", id.ReplicationProtectionClusterName), + } + return fmt.Sprintf("Replication Protection Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_replicationprotectioncluster_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_replicationprotectioncluster_test.go new file mode 100644 index 00000000000..51d21c9522d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_replicationprotectioncluster_test.go @@ -0,0 +1,417 @@ +package replicationprotectionclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectionClusterId{} + +func TestNewReplicationProtectionClusterID(t *testing.T) { + id := NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectionClusterName != "replicationProtectionClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionClusterName'", id.ReplicationProtectionClusterName, "replicationProtectionClusterName") + } +} + +func TestFormatReplicationProtectionClusterID(t *testing.T) { + actual := NewReplicationProtectionClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName", + Expected: &ReplicationProtectionClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionClusterName: "replicationProtectionClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionClusterName != v.Expected.ReplicationProtectionClusterName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionClusterName", v.Expected.ReplicationProtectionClusterName, actual.ReplicationProtectionClusterName) + } + + } +} + +func TestParseReplicationProtectionClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName", + Expected: &ReplicationProtectionClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionClusterName: "replicationProtectionClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionClusters/replicationProtectionClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE", + Expected: &ReplicationProtectionClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectionClusterName: "rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnClUsTeRs/rEpLiCaTiOnPrOtEcTiOnClUsTeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionClusterName != v.Expected.ReplicationProtectionClusterName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionClusterName", v.Expected.ReplicationProtectionClusterName, actual.ReplicationProtectionClusterName) + } + + } +} + +func TestSegmentsForReplicationProtectionClusterId(t *testing.T) { + segments := ReplicationProtectionClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionClusterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..e6dc5092a4b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_replicationprotectioncontainer.go @@ -0,0 +1,148 @@ +package replicationprotectionclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectionContainerId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..0a7fb19397c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationprotectionclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_vault.go new file mode 100644 index 00000000000..cc7c01caea9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_vault.go @@ -0,0 +1,130 @@ +package replicationprotectionclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_vault_test.go new file mode 100644 index 00000000000..c0019a94ada --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationprotectionclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_applyrecoverypoint.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_applyrecoverypoint.go new file mode 100644 index 00000000000..09bbe7917ee --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_applyrecoverypoint.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplyRecoveryPointOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionCluster +} + +// ApplyRecoveryPoint ... +func (c ReplicationProtectionClustersClient) ApplyRecoveryPoint(ctx context.Context, id ReplicationProtectionClusterId, input ApplyClusterRecoveryPointInput) (result ApplyRecoveryPointOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applyRecoveryPoint", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ApplyRecoveryPointThenPoll performs ApplyRecoveryPoint then polls until it's completed +func (c ReplicationProtectionClustersClient) ApplyRecoveryPointThenPoll(ctx context.Context, id ReplicationProtectionClusterId, input ApplyClusterRecoveryPointInput) error { + result, err := c.ApplyRecoveryPoint(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApplyRecoveryPoint: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApplyRecoveryPoint: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_create.go new file mode 100644 index 00000000000..87b2547fe6c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_create.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ReplicationProtectionCluster +} + +// Create ... +func (c ReplicationProtectionClustersClient) Create(ctx context.Context, id ReplicationProtectionClusterId, input ReplicationProtectionCluster) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationProtectionClustersClient) CreateThenPoll(ctx context.Context, id ReplicationProtectionClusterId, input ReplicationProtectionCluster) 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/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_failovercommit.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_failovercommit.go new file mode 100644 index 00000000000..0262815801a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_failovercommit.go @@ -0,0 +1,71 @@ +package replicationprotectionclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverCommitOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionCluster +} + +// FailoverCommit ... +func (c ReplicationProtectionClustersClient) FailoverCommit(ctx context.Context, id ReplicationProtectionClusterId) (result FailoverCommitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverCommit", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// FailoverCommitThenPoll performs FailoverCommit then polls until it's completed +func (c ReplicationProtectionClustersClient) FailoverCommitThenPoll(ctx context.Context, id ReplicationProtectionClusterId) error { + result, err := c.FailoverCommit(ctx, id) + if err != nil { + return fmt.Errorf("performing FailoverCommit: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FailoverCommit: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_get.go new file mode 100644 index 00000000000..21d0209de27 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_get.go @@ -0,0 +1,53 @@ +package replicationprotectionclusters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ReplicationProtectionCluster +} + +// Get ... +func (c ReplicationProtectionClustersClient) Get(ctx context.Context, id ReplicationProtectionClusterId) (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 ReplicationProtectionCluster + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_list.go new file mode 100644 index 00000000000..006c98e0ece --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_list.go @@ -0,0 +1,138 @@ +package replicationprotectionclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ReplicationProtectionCluster +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationProtectionCluster +} + +type ListOperationOptions struct { + Filter *string + SkipToken *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)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + 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 ReplicationProtectionClustersClient) List(ctx context.Context, id VaultId, 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/replicationProtectionClusters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReplicationProtectionCluster `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 ReplicationProtectionClustersClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ReplicationProtectionClusterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionClustersClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ReplicationProtectionClusterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ReplicationProtectionCluster, 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/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_listbyreplicationprotectioncontainers.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_listbyreplicationprotectioncontainers.go new file mode 100644 index 00000000000..ec679c4b218 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_listbyreplicationprotectioncontainers.go @@ -0,0 +1,105 @@ +package replicationprotectionclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationProtectionContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReplicationProtectionCluster +} + +type ListByReplicationProtectionContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationProtectionCluster +} + +type ListByReplicationProtectionContainersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectionContainersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectionContainers ... +func (c ReplicationProtectionClustersClient) ListByReplicationProtectionContainers(ctx context.Context, id ReplicationProtectionContainerId) (result ListByReplicationProtectionContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationProtectionContainersCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectionClusters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReplicationProtectionCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionContainersComplete retrieves all the results into a single object +func (c ReplicationProtectionClustersClient) ListByReplicationProtectionContainersComplete(ctx context.Context, id ReplicationProtectionContainerId) (ListByReplicationProtectionContainersCompleteResult, error) { + return c.ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx, id, ReplicationProtectionClusterOperationPredicate{}) +} + +// ListByReplicationProtectionContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionClustersClient) ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionContainerId, predicate ReplicationProtectionClusterOperationPredicate) (result ListByReplicationProtectionContainersCompleteResult, err error) { + items := make([]ReplicationProtectionCluster, 0) + + resp, err := c.ListByReplicationProtectionContainers(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 = ListByReplicationProtectionContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_purge.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_purge.go new file mode 100644 index 00000000000..93ef7814b77 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_purge.go @@ -0,0 +1,70 @@ +package replicationprotectionclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c ReplicationProtectionClustersClient) Purge(ctx context.Context, id ReplicationProtectionClusterId) (result PurgeOperationResponse, 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 +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c ReplicationProtectionClustersClient) PurgeThenPoll(ctx context.Context, id ReplicationProtectionClusterId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_repairreplication.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_repairreplication.go new file mode 100644 index 00000000000..91457971e2a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_repairreplication.go @@ -0,0 +1,71 @@ +package replicationprotectionclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RepairReplicationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionCluster +} + +// RepairReplication ... +func (c ReplicationProtectionClustersClient) RepairReplication(ctx context.Context, id ReplicationProtectionClusterId) (result RepairReplicationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/repairReplication", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RepairReplicationThenPoll performs RepairReplication then polls until it's completed +func (c ReplicationProtectionClustersClient) RepairReplicationThenPoll(ctx context.Context, id ReplicationProtectionClusterId) error { + result, err := c.RepairReplication(ctx, id) + if err != nil { + return fmt.Errorf("performing RepairReplication: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RepairReplication: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_testfailover.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_testfailover.go new file mode 100644 index 00000000000..e17d6e94e62 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_testfailover.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionCluster +} + +// TestFailover ... +func (c ReplicationProtectionClustersClient) TestFailover(ctx context.Context, id ReplicationProtectionClusterId, input ClusterTestFailoverInput) (result TestFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// TestFailoverThenPoll performs TestFailover then polls until it's completed +func (c ReplicationProtectionClustersClient) TestFailoverThenPoll(ctx context.Context, id ReplicationProtectionClusterId, input ClusterTestFailoverInput) error { + result, err := c.TestFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_testfailovercleanup.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_testfailovercleanup.go new file mode 100644 index 00000000000..cb6b2b2036d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_testfailovercleanup.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverCleanupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionCluster +} + +// TestFailoverCleanup ... +func (c ReplicationProtectionClustersClient) TestFailoverCleanup(ctx context.Context, id ReplicationProtectionClusterId, input ClusterTestFailoverCleanupInput) (result TestFailoverCleanupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailoverCleanup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// TestFailoverCleanupThenPoll performs TestFailoverCleanup then polls until it's completed +func (c ReplicationProtectionClustersClient) TestFailoverCleanupThenPoll(ctx context.Context, id ReplicationProtectionClusterId, input ClusterTestFailoverCleanupInput) error { + result, err := c.TestFailoverCleanup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailoverCleanup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailoverCleanup: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_unplannedfailover.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_unplannedfailover.go new file mode 100644 index 00000000000..291c3933255 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/method_unplannedfailover.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnplannedFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationProtectionCluster +} + +// UnplannedFailover ... +func (c ReplicationProtectionClustersClient) UnplannedFailover(ctx context.Context, id ReplicationProtectionClusterId, input ClusterUnplannedFailoverInput) (result UnplannedFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/unplannedFailover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UnplannedFailoverThenPoll performs UnplannedFailover then polls until it's completed +func (c ReplicationProtectionClustersClient) UnplannedFailoverThenPoll(ctx context.Context, id ReplicationProtectionClusterId, input ClusterUnplannedFailoverInput) error { + result, err := c.UnplannedFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UnplannedFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UnplannedFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aapplyclusterrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aapplyclusterrecoverypointinput.go new file mode 100644 index 00000000000..d6cdb3e3030 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aapplyclusterrecoverypointinput.go @@ -0,0 +1,49 @@ +package replicationprotectionclusters + +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 _ ApplyClusterRecoveryPointProviderSpecificInput = A2AApplyClusterRecoveryPointInput{} + +type A2AApplyClusterRecoveryPointInput struct { + + // Fields inherited from ApplyClusterRecoveryPointProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AApplyClusterRecoveryPointInput) ApplyClusterRecoveryPointProviderSpecificInput() BaseApplyClusterRecoveryPointProviderSpecificInputImpl { + return BaseApplyClusterRecoveryPointProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AApplyClusterRecoveryPointInput{} + +func (s A2AApplyClusterRecoveryPointInput) MarshalJSON() ([]byte, error) { + type wrapper A2AApplyClusterRecoveryPointInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AApplyClusterRecoveryPointInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AApplyClusterRecoveryPointInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AApplyClusterRecoveryPointInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aclustertestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aclustertestfailoverinput.go new file mode 100644 index 00000000000..dc11ca955f1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aclustertestfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotectionclusters + +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 _ ClusterTestFailoverProviderSpecificInput = A2AClusterTestFailoverInput{} + +type A2AClusterTestFailoverInput struct { + ClusterRecoveryPointId *string `json:"clusterRecoveryPointId,omitempty"` + IndividualNodeRecoveryPoints *[]string `json:"individualNodeRecoveryPoints,omitempty"` + + // Fields inherited from ClusterTestFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AClusterTestFailoverInput) ClusterTestFailoverProviderSpecificInput() BaseClusterTestFailoverProviderSpecificInputImpl { + return BaseClusterTestFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AClusterTestFailoverInput{} + +func (s A2AClusterTestFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper A2AClusterTestFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AClusterTestFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AClusterTestFailoverInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AClusterTestFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aclusterunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aclusterunplannedfailoverinput.go new file mode 100644 index 00000000000..193f06824e4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aclusterunplannedfailoverinput.go @@ -0,0 +1,51 @@ +package replicationprotectionclusters + +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 _ ClusterUnplannedFailoverProviderSpecificInput = A2AClusterUnplannedFailoverInput{} + +type A2AClusterUnplannedFailoverInput struct { + ClusterRecoveryPointId *string `json:"clusterRecoveryPointId,omitempty"` + IndividualNodeRecoveryPoints *[]string `json:"individualNodeRecoveryPoints,omitempty"` + + // Fields inherited from ClusterUnplannedFailoverProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AClusterUnplannedFailoverInput) ClusterUnplannedFailoverProviderSpecificInput() BaseClusterUnplannedFailoverProviderSpecificInputImpl { + return BaseClusterUnplannedFailoverProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AClusterUnplannedFailoverInput{} + +func (s A2AClusterUnplannedFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper A2AClusterUnplannedFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AClusterUnplannedFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AClusterUnplannedFailoverInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AClusterUnplannedFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aprotectedmanageddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aprotectedmanageddiskdetails.go new file mode 100644 index 00000000000..c419fd49ad2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aprotectedmanageddiskdetails.go @@ -0,0 +1,35 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AProtectedManagedDiskDetails struct { + AllowedDiskLevelOperation *[]string `json:"allowedDiskLevelOperation,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` + DataPendingInStagingStorageAccountInMB *float64 `json:"dataPendingInStagingStorageAccountInMB,omitempty"` + DekKeyVaultArmId *string `json:"dekKeyVaultArmId,omitempty"` + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + DiskId *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskState *string `json:"diskState,omitempty"` + DiskType *string `json:"diskType,omitempty"` + FailoverDiskName *string `json:"failoverDiskName,omitempty"` + IsDiskEncrypted *bool `json:"isDiskEncrypted,omitempty"` + IsDiskKeyEncrypted *bool `json:"isDiskKeyEncrypted,omitempty"` + KekKeyVaultArmId *string `json:"kekKeyVaultArmId,omitempty"` + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + MonitoringPercentageCompletion *int64 `json:"monitoringPercentageCompletion,omitempty"` + PrimaryDiskEncryptionSetId *string `json:"primaryDiskEncryptionSetId,omitempty"` + PrimaryStagingAzureStorageAccountId *string `json:"primaryStagingAzureStorageAccountId,omitempty"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryOrignalTargetDiskId *string `json:"recoveryOrignalTargetDiskId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryReplicaDiskId *string `json:"recoveryReplicaDiskId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` + RecoveryTargetDiskId *string `json:"recoveryTargetDiskId,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` + TfoDiskName *string `json:"tfoDiskName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2areplicationprotectionclusterdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2areplicationprotectionclusterdetails.go new file mode 100644 index 00000000000..2a04b366aca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2areplicationprotectionclusterdetails.go @@ -0,0 +1,71 @@ +package replicationprotectionclusters + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ReplicationClusterProviderSpecificSettings = A2AReplicationProtectionClusterDetails{} + +type A2AReplicationProtectionClusterDetails struct { + ClusterManagementId *string `json:"clusterManagementId,omitempty"` + FailoverRecoveryPointId *string `json:"failoverRecoveryPointId,omitempty"` + InitialPrimaryExtendedLocation *edgezones.Model `json:"initialPrimaryExtendedLocation,omitempty"` + InitialPrimaryFabricLocation *string `json:"initialPrimaryFabricLocation,omitempty"` + InitialPrimaryZone *string `json:"initialPrimaryZone,omitempty"` + InitialRecoveryExtendedLocation *edgezones.Model `json:"initialRecoveryExtendedLocation,omitempty"` + InitialRecoveryFabricLocation *string `json:"initialRecoveryFabricLocation,omitempty"` + InitialRecoveryZone *string `json:"initialRecoveryZone,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + LifecycleId *string `json:"lifecycleId,omitempty"` + MultiVMGroupCreateOption *MultiVMGroupCreateOption `json:"multiVmGroupCreateOption,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + PrimaryAvailabilityZone *string `json:"primaryAvailabilityZone,omitempty"` + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + + // Fields inherited from ReplicationClusterProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s A2AReplicationProtectionClusterDetails) ReplicationClusterProviderSpecificSettings() BaseReplicationClusterProviderSpecificSettingsImpl { + return BaseReplicationClusterProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AReplicationProtectionClusterDetails{} + +func (s A2AReplicationProtectionClusterDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AReplicationProtectionClusterDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AReplicationProtectionClusterDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AReplicationProtectionClusterDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AReplicationProtectionClusterDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2ashareddiskirerrordetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2ashareddiskirerrordetails.go new file mode 100644 index 00000000000..b48c423892c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2ashareddiskirerrordetails.go @@ -0,0 +1,12 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2ASharedDiskIRErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorCodeEnum *string `json:"errorCodeEnum,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2ashareddiskreplicationdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2ashareddiskreplicationdetails.go new file mode 100644 index 00000000000..8532960ff6a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2ashareddiskreplicationdetails.go @@ -0,0 +1,60 @@ +package replicationprotectionclusters + +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 _ SharedDiskReplicationProviderSpecificSettings = A2ASharedDiskReplicationDetails{} + +type A2ASharedDiskReplicationDetails struct { + FailoverRecoveryPointId *string `json:"failoverRecoveryPointId,omitempty"` + LastRpoCalculatedTime *string `json:"lastRpoCalculatedTime,omitempty"` + ManagementId *string `json:"managementId,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + MonitoringPercentageCompletion *int64 `json:"monitoringPercentageCompletion,omitempty"` + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + ProtectedManagedDisks *[]A2AProtectedManagedDiskDetails `json:"protectedManagedDisks,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + SharedDiskIRErrors *[]A2ASharedDiskIRErrorDetails `json:"sharedDiskIRErrors,omitempty"` + UnprotectedDisks *[]A2AUnprotectedDiskDetails `json:"unprotectedDisks,omitempty"` + + // Fields inherited from SharedDiskReplicationProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s A2ASharedDiskReplicationDetails) SharedDiskReplicationProviderSpecificSettings() BaseSharedDiskReplicationProviderSpecificSettingsImpl { + return BaseSharedDiskReplicationProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ASharedDiskReplicationDetails{} + +func (s A2ASharedDiskReplicationDetails) MarshalJSON() ([]byte, error) { + type wrapper A2ASharedDiskReplicationDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ASharedDiskReplicationDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ASharedDiskReplicationDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ASharedDiskReplicationDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aunprotecteddiskdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aunprotecteddiskdetails.go new file mode 100644 index 00000000000..1a470d445cf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_a2aunprotecteddiskdetails.go @@ -0,0 +1,9 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AUnprotectedDiskDetails struct { + DiskAutoProtectionStatus *AutoProtectionOfDataDisk `json:"diskAutoProtectionStatus,omitempty"` + DiskLunId *int64 `json:"diskLunId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_applyclusterrecoverypointinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_applyclusterrecoverypointinput.go new file mode 100644 index 00000000000..c281b09c9bf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_applyclusterrecoverypointinput.go @@ -0,0 +1,8 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplyClusterRecoveryPointInput struct { + Properties ApplyClusterRecoveryPointInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_applyclusterrecoverypointinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_applyclusterrecoverypointinputproperties.go new file mode 100644 index 00000000000..6f4e17b8a4b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_applyclusterrecoverypointinputproperties.go @@ -0,0 +1,45 @@ +package replicationprotectionclusters + +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 ApplyClusterRecoveryPointInputProperties struct { + ClusterRecoveryPointId *string `json:"clusterRecoveryPointId,omitempty"` + IndividualNodeRecoveryPoints *[]string `json:"individualNodeRecoveryPoints,omitempty"` + ProviderSpecificDetails ApplyClusterRecoveryPointProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ApplyClusterRecoveryPointInputProperties{} + +func (s *ApplyClusterRecoveryPointInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ClusterRecoveryPointId *string `json:"clusterRecoveryPointId,omitempty"` + IndividualNodeRecoveryPoints *[]string `json:"individualNodeRecoveryPoints,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ClusterRecoveryPointId = decoded.ClusterRecoveryPointId + s.IndividualNodeRecoveryPoints = decoded.IndividualNodeRecoveryPoints + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ApplyClusterRecoveryPointInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalApplyClusterRecoveryPointProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ApplyClusterRecoveryPointInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_applyclusterrecoverypointproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_applyclusterrecoverypointproviderspecificinput.go new file mode 100644 index 00000000000..a8bf8d19ab9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_applyclusterrecoverypointproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 ApplyClusterRecoveryPointProviderSpecificInput interface { + ApplyClusterRecoveryPointProviderSpecificInput() BaseApplyClusterRecoveryPointProviderSpecificInputImpl +} + +var _ ApplyClusterRecoveryPointProviderSpecificInput = BaseApplyClusterRecoveryPointProviderSpecificInputImpl{} + +type BaseApplyClusterRecoveryPointProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseApplyClusterRecoveryPointProviderSpecificInputImpl) ApplyClusterRecoveryPointProviderSpecificInput() BaseApplyClusterRecoveryPointProviderSpecificInputImpl { + return s +} + +var _ ApplyClusterRecoveryPointProviderSpecificInput = RawApplyClusterRecoveryPointProviderSpecificInputImpl{} + +// RawApplyClusterRecoveryPointProviderSpecificInputImpl 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 RawApplyClusterRecoveryPointProviderSpecificInputImpl struct { + applyClusterRecoveryPointProviderSpecificInput BaseApplyClusterRecoveryPointProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawApplyClusterRecoveryPointProviderSpecificInputImpl) ApplyClusterRecoveryPointProviderSpecificInput() BaseApplyClusterRecoveryPointProviderSpecificInputImpl { + return s.applyClusterRecoveryPointProviderSpecificInput +} + +func UnmarshalApplyClusterRecoveryPointProviderSpecificInputImplementation(input []byte) (ApplyClusterRecoveryPointProviderSpecificInput, 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 ApplyClusterRecoveryPointProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AApplyClusterRecoveryPointInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AApplyClusterRecoveryPointInput: %+v", err) + } + return out, nil + } + + var parent BaseApplyClusterRecoveryPointProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseApplyClusterRecoveryPointProviderSpecificInputImpl: %+v", err) + } + + return RawApplyClusterRecoveryPointProviderSpecificInputImpl{ + applyClusterRecoveryPointProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailovercleanupinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailovercleanupinput.go new file mode 100644 index 00000000000..93ae8de96ec --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailovercleanupinput.go @@ -0,0 +1,8 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterTestFailoverCleanupInput struct { + Properties ClusterTestFailoverCleanupInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailovercleanupinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailovercleanupinputproperties.go new file mode 100644 index 00000000000..70381c1c3c8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailovercleanupinputproperties.go @@ -0,0 +1,8 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterTestFailoverCleanupInputProperties struct { + Comments *string `json:"comments,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailoverinput.go new file mode 100644 index 00000000000..7599d6a69c3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailoverinput.go @@ -0,0 +1,8 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterTestFailoverInput struct { + Properties ClusterTestFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailoverinputproperties.go new file mode 100644 index 00000000000..978eaa42cf2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailoverinputproperties.go @@ -0,0 +1,48 @@ +package replicationprotectionclusters + +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 ClusterTestFailoverInputProperties struct { + FailoverDirection *FailoverDirection `json:"failoverDirection,omitempty"` + NetworkId *string `json:"networkId,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + ProviderSpecificDetails ClusterTestFailoverProviderSpecificInput `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ClusterTestFailoverInputProperties{} + +func (s *ClusterTestFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection *FailoverDirection `json:"failoverDirection,omitempty"` + NetworkId *string `json:"networkId,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.NetworkId = decoded.NetworkId + s.NetworkType = decoded.NetworkType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ClusterTestFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalClusterTestFailoverProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ClusterTestFailoverInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailoverproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailoverproviderspecificinput.go new file mode 100644 index 00000000000..e3a38850917 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clustertestfailoverproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 ClusterTestFailoverProviderSpecificInput interface { + ClusterTestFailoverProviderSpecificInput() BaseClusterTestFailoverProviderSpecificInputImpl +} + +var _ ClusterTestFailoverProviderSpecificInput = BaseClusterTestFailoverProviderSpecificInputImpl{} + +type BaseClusterTestFailoverProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseClusterTestFailoverProviderSpecificInputImpl) ClusterTestFailoverProviderSpecificInput() BaseClusterTestFailoverProviderSpecificInputImpl { + return s +} + +var _ ClusterTestFailoverProviderSpecificInput = RawClusterTestFailoverProviderSpecificInputImpl{} + +// RawClusterTestFailoverProviderSpecificInputImpl 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 RawClusterTestFailoverProviderSpecificInputImpl struct { + clusterTestFailoverProviderSpecificInput BaseClusterTestFailoverProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawClusterTestFailoverProviderSpecificInputImpl) ClusterTestFailoverProviderSpecificInput() BaseClusterTestFailoverProviderSpecificInputImpl { + return s.clusterTestFailoverProviderSpecificInput +} + +func UnmarshalClusterTestFailoverProviderSpecificInputImplementation(input []byte) (ClusterTestFailoverProviderSpecificInput, 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 ClusterTestFailoverProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AClusterTestFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AClusterTestFailoverInput: %+v", err) + } + return out, nil + } + + var parent BaseClusterTestFailoverProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseClusterTestFailoverProviderSpecificInputImpl: %+v", err) + } + + return RawClusterTestFailoverProviderSpecificInputImpl{ + clusterTestFailoverProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clusterunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clusterunplannedfailoverinput.go new file mode 100644 index 00000000000..b44b21c5478 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clusterunplannedfailoverinput.go @@ -0,0 +1,8 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterUnplannedFailoverInput struct { + Properties ClusterUnplannedFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clusterunplannedfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clusterunplannedfailoverinputproperties.go new file mode 100644 index 00000000000..0760209d43e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clusterunplannedfailoverinputproperties.go @@ -0,0 +1,45 @@ +package replicationprotectionclusters + +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 ClusterUnplannedFailoverInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + ProviderSpecificDetails ClusterUnplannedFailoverProviderSpecificInput `json:"providerSpecificDetails"` + SourceSiteOperations *string `json:"sourceSiteOperations,omitempty"` +} + +var _ json.Unmarshaler = &ClusterUnplannedFailoverInputProperties{} + +func (s *ClusterUnplannedFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + SourceSiteOperations *string `json:"sourceSiteOperations,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.SourceSiteOperations = decoded.SourceSiteOperations + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ClusterUnplannedFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalClusterUnplannedFailoverProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ClusterUnplannedFailoverInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clusterunplannedfailoverproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clusterunplannedfailoverproviderspecificinput.go new file mode 100644 index 00000000000..e1a10248f08 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_clusterunplannedfailoverproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 ClusterUnplannedFailoverProviderSpecificInput interface { + ClusterUnplannedFailoverProviderSpecificInput() BaseClusterUnplannedFailoverProviderSpecificInputImpl +} + +var _ ClusterUnplannedFailoverProviderSpecificInput = BaseClusterUnplannedFailoverProviderSpecificInputImpl{} + +type BaseClusterUnplannedFailoverProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseClusterUnplannedFailoverProviderSpecificInputImpl) ClusterUnplannedFailoverProviderSpecificInput() BaseClusterUnplannedFailoverProviderSpecificInputImpl { + return s +} + +var _ ClusterUnplannedFailoverProviderSpecificInput = RawClusterUnplannedFailoverProviderSpecificInputImpl{} + +// RawClusterUnplannedFailoverProviderSpecificInputImpl 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 RawClusterUnplannedFailoverProviderSpecificInputImpl struct { + clusterUnplannedFailoverProviderSpecificInput BaseClusterUnplannedFailoverProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawClusterUnplannedFailoverProviderSpecificInputImpl) ClusterUnplannedFailoverProviderSpecificInput() BaseClusterUnplannedFailoverProviderSpecificInputImpl { + return s.clusterUnplannedFailoverProviderSpecificInput +} + +func UnmarshalClusterUnplannedFailoverProviderSpecificInputImplementation(input []byte) (ClusterUnplannedFailoverProviderSpecificInput, 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 ClusterUnplannedFailoverProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AClusterUnplannedFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AClusterUnplannedFailoverInput: %+v", err) + } + return out, nil + } + + var parent BaseClusterUnplannedFailoverProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseClusterUnplannedFailoverProviderSpecificInputImpl: %+v", err) + } + + return RawClusterUnplannedFailoverProviderSpecificInputImpl{ + clusterUnplannedFailoverProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_currentscenariodetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_currentscenariodetails.go new file mode 100644 index 00000000000..a4ec2bfa40b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_currentscenariodetails.go @@ -0,0 +1,28 @@ +package replicationprotectionclusters + +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 CurrentScenarioDetails struct { + JobId *string `json:"jobId,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *CurrentScenarioDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CurrentScenarioDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_healtherror.go new file mode 100644 index 00000000000..77565f1e7dd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationprotectionclusters + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_innerhealtherror.go new file mode 100644 index 00000000000..08deeff4fc4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationprotectionclusters + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_registeredclusternodes.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_registeredclusternodes.go new file mode 100644 index 00000000000..2a72fdf3bbd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_registeredclusternodes.go @@ -0,0 +1,11 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegisteredClusterNodes struct { + BiosId *string `json:"biosId,omitempty"` + ClusterNodeFqdn *string `json:"clusterNodeFqdn,omitempty"` + IsSharedDiskVirtualNode *bool `json:"isSharedDiskVirtualNode,omitempty"` + MachineId *string `json:"machineId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_replicationclusterproviderspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_replicationclusterproviderspecificsettings.go new file mode 100644 index 00000000000..4da11d823da --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_replicationclusterproviderspecificsettings.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 ReplicationClusterProviderSpecificSettings interface { + ReplicationClusterProviderSpecificSettings() BaseReplicationClusterProviderSpecificSettingsImpl +} + +var _ ReplicationClusterProviderSpecificSettings = BaseReplicationClusterProviderSpecificSettingsImpl{} + +type BaseReplicationClusterProviderSpecificSettingsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseReplicationClusterProviderSpecificSettingsImpl) ReplicationClusterProviderSpecificSettings() BaseReplicationClusterProviderSpecificSettingsImpl { + return s +} + +var _ ReplicationClusterProviderSpecificSettings = RawReplicationClusterProviderSpecificSettingsImpl{} + +// RawReplicationClusterProviderSpecificSettingsImpl 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 RawReplicationClusterProviderSpecificSettingsImpl struct { + replicationClusterProviderSpecificSettings BaseReplicationClusterProviderSpecificSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawReplicationClusterProviderSpecificSettingsImpl) ReplicationClusterProviderSpecificSettings() BaseReplicationClusterProviderSpecificSettingsImpl { + return s.replicationClusterProviderSpecificSettings +} + +func UnmarshalReplicationClusterProviderSpecificSettingsImplementation(input []byte) (ReplicationClusterProviderSpecificSettings, 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 ReplicationClusterProviderSpecificSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AReplicationProtectionClusterDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AReplicationProtectionClusterDetails: %+v", err) + } + return out, nil + } + + var parent BaseReplicationClusterProviderSpecificSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseReplicationClusterProviderSpecificSettingsImpl: %+v", err) + } + + return RawReplicationClusterProviderSpecificSettingsImpl{ + replicationClusterProviderSpecificSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_replicationprotectioncluster.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_replicationprotectioncluster.go new file mode 100644 index 00000000000..1590713495a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_replicationprotectioncluster.go @@ -0,0 +1,11 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectionCluster struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReplicationProtectionClusterProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_replicationprotectionclusterproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_replicationprotectionclusterproperties.go new file mode 100644 index 00000000000..527933170f3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_replicationprotectionclusterproperties.go @@ -0,0 +1,153 @@ +package replicationprotectionclusters + +import ( + "encoding/json" + "fmt" + "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 ReplicationProtectionClusterProperties struct { + ActiveLocation *string `json:"activeLocation,omitempty"` + AgentClusterId *string `json:"agentClusterId,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + AreAllClusterNodesRegistered *bool `json:"areAllClusterNodesRegistered,omitempty"` + ClusterFqdn *string `json:"clusterFqdn,omitempty"` + ClusterNodeFqdns *[]string `json:"clusterNodeFqdns,omitempty"` + ClusterProtectedItemIds *[]string `json:"clusterProtectedItemIds,omitempty"` + ClusterRegisteredNodes *[]RegisteredClusterNodes `json:"clusterRegisteredNodes,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + LastSuccessfulFailoverTime *string `json:"lastSuccessfulFailoverTime,omitempty"` + LastSuccessfulTestFailoverTime *string `json:"lastSuccessfulTestFailoverTime,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryFabricProvider *string `json:"primaryFabricProvider,omitempty"` + PrimaryProtectionContainerFriendlyName *string `json:"primaryProtectionContainerFriendlyName,omitempty"` + ProtectionClusterType *string `json:"protectionClusterType,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + ProtectionStateDescription *string `json:"protectionStateDescription,omitempty"` + ProviderSpecificDetails ReplicationClusterProviderSpecificSettings `json:"providerSpecificDetails"` + ProvisioningState *string `json:"provisioningState,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricId *string `json:"recoveryFabricId,omitempty"` + RecoveryProtectionContainerFriendlyName *string `json:"recoveryProtectionContainerFriendlyName,omitempty"` + ReplicationHealth *string `json:"replicationHealth,omitempty"` + SharedDiskProperties *SharedDiskReplicationItemProperties `json:"sharedDiskProperties,omitempty"` + TestFailoverState *string `json:"testFailoverState,omitempty"` + TestFailoverStateDescription *string `json:"testFailoverStateDescription,omitempty"` +} + +func (o *ReplicationProtectionClusterProperties) GetLastSuccessfulFailoverTimeAsTime() (*time.Time, error) { + if o.LastSuccessfulFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastSuccessfulFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationProtectionClusterProperties) SetLastSuccessfulFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastSuccessfulFailoverTime = &formatted +} + +func (o *ReplicationProtectionClusterProperties) GetLastSuccessfulTestFailoverTimeAsTime() (*time.Time, error) { + if o.LastSuccessfulTestFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastSuccessfulTestFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicationProtectionClusterProperties) SetLastSuccessfulTestFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastSuccessfulTestFailoverTime = &formatted +} + +var _ json.Unmarshaler = &ReplicationProtectionClusterProperties{} + +func (s *ReplicationProtectionClusterProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ActiveLocation *string `json:"activeLocation,omitempty"` + AgentClusterId *string `json:"agentClusterId,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + AreAllClusterNodesRegistered *bool `json:"areAllClusterNodesRegistered,omitempty"` + ClusterFqdn *string `json:"clusterFqdn,omitempty"` + ClusterNodeFqdns *[]string `json:"clusterNodeFqdns,omitempty"` + ClusterProtectedItemIds *[]string `json:"clusterProtectedItemIds,omitempty"` + ClusterRegisteredNodes *[]RegisteredClusterNodes `json:"clusterRegisteredNodes,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + LastSuccessfulFailoverTime *string `json:"lastSuccessfulFailoverTime,omitempty"` + LastSuccessfulTestFailoverTime *string `json:"lastSuccessfulTestFailoverTime,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryFabricProvider *string `json:"primaryFabricProvider,omitempty"` + PrimaryProtectionContainerFriendlyName *string `json:"primaryProtectionContainerFriendlyName,omitempty"` + ProtectionClusterType *string `json:"protectionClusterType,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + ProtectionStateDescription *string `json:"protectionStateDescription,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricId *string `json:"recoveryFabricId,omitempty"` + RecoveryProtectionContainerFriendlyName *string `json:"recoveryProtectionContainerFriendlyName,omitempty"` + ReplicationHealth *string `json:"replicationHealth,omitempty"` + SharedDiskProperties *SharedDiskReplicationItemProperties `json:"sharedDiskProperties,omitempty"` + TestFailoverState *string `json:"testFailoverState,omitempty"` + TestFailoverStateDescription *string `json:"testFailoverStateDescription,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ActiveLocation = decoded.ActiveLocation + s.AgentClusterId = decoded.AgentClusterId + s.AllowedOperations = decoded.AllowedOperations + s.AreAllClusterNodesRegistered = decoded.AreAllClusterNodesRegistered + s.ClusterFqdn = decoded.ClusterFqdn + s.ClusterNodeFqdns = decoded.ClusterNodeFqdns + s.ClusterProtectedItemIds = decoded.ClusterProtectedItemIds + s.ClusterRegisteredNodes = decoded.ClusterRegisteredNodes + s.CurrentScenario = decoded.CurrentScenario + s.HealthErrors = decoded.HealthErrors + s.LastSuccessfulFailoverTime = decoded.LastSuccessfulFailoverTime + s.LastSuccessfulTestFailoverTime = decoded.LastSuccessfulTestFailoverTime + s.PolicyFriendlyName = decoded.PolicyFriendlyName + s.PolicyId = decoded.PolicyId + s.PrimaryFabricFriendlyName = decoded.PrimaryFabricFriendlyName + s.PrimaryFabricProvider = decoded.PrimaryFabricProvider + s.PrimaryProtectionContainerFriendlyName = decoded.PrimaryProtectionContainerFriendlyName + s.ProtectionClusterType = decoded.ProtectionClusterType + s.ProtectionState = decoded.ProtectionState + s.ProtectionStateDescription = decoded.ProtectionStateDescription + s.ProvisioningState = decoded.ProvisioningState + s.RecoveryContainerId = decoded.RecoveryContainerId + s.RecoveryFabricFriendlyName = decoded.RecoveryFabricFriendlyName + s.RecoveryFabricId = decoded.RecoveryFabricId + s.RecoveryProtectionContainerFriendlyName = decoded.RecoveryProtectionContainerFriendlyName + s.ReplicationHealth = decoded.ReplicationHealth + s.SharedDiskProperties = decoded.SharedDiskProperties + s.TestFailoverState = decoded.TestFailoverState + s.TestFailoverStateDescription = decoded.TestFailoverStateDescription + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ReplicationProtectionClusterProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalReplicationClusterProviderSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ReplicationProtectionClusterProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_shareddiskreplicationitemproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_shareddiskreplicationitemproperties.go new file mode 100644 index 00000000000..60fbba1a93e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_shareddiskreplicationitemproperties.go @@ -0,0 +1,60 @@ +package replicationprotectionclusters + +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 SharedDiskReplicationItemProperties struct { + ActiveLocation *string `json:"activeLocation,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + ReplicationHealth *string `json:"replicationHealth,omitempty"` + SharedDiskProviderSpecificDetails SharedDiskReplicationProviderSpecificSettings `json:"sharedDiskProviderSpecificDetails"` + TestFailoverState *string `json:"testFailoverState,omitempty"` +} + +var _ json.Unmarshaler = &SharedDiskReplicationItemProperties{} + +func (s *SharedDiskReplicationItemProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ActiveLocation *string `json:"activeLocation,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + ReplicationHealth *string `json:"replicationHealth,omitempty"` + TestFailoverState *string `json:"testFailoverState,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ActiveLocation = decoded.ActiveLocation + s.AllowedOperations = decoded.AllowedOperations + s.CurrentScenario = decoded.CurrentScenario + s.HealthErrors = decoded.HealthErrors + s.ProtectionState = decoded.ProtectionState + s.ReplicationHealth = decoded.ReplicationHealth + s.TestFailoverState = decoded.TestFailoverState + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SharedDiskReplicationItemProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["sharedDiskProviderSpecificDetails"]; ok { + impl, err := UnmarshalSharedDiskReplicationProviderSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SharedDiskProviderSpecificDetails' for 'SharedDiskReplicationItemProperties': %+v", err) + } + s.SharedDiskProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_shareddiskreplicationproviderspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_shareddiskreplicationproviderspecificsettings.go new file mode 100644 index 00000000000..ba7d1ed5746 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/model_shareddiskreplicationproviderspecificsettings.go @@ -0,0 +1,75 @@ +package replicationprotectionclusters + +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 SharedDiskReplicationProviderSpecificSettings interface { + SharedDiskReplicationProviderSpecificSettings() BaseSharedDiskReplicationProviderSpecificSettingsImpl +} + +var _ SharedDiskReplicationProviderSpecificSettings = BaseSharedDiskReplicationProviderSpecificSettingsImpl{} + +type BaseSharedDiskReplicationProviderSpecificSettingsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseSharedDiskReplicationProviderSpecificSettingsImpl) SharedDiskReplicationProviderSpecificSettings() BaseSharedDiskReplicationProviderSpecificSettingsImpl { + return s +} + +var _ SharedDiskReplicationProviderSpecificSettings = RawSharedDiskReplicationProviderSpecificSettingsImpl{} + +// RawSharedDiskReplicationProviderSpecificSettingsImpl 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 RawSharedDiskReplicationProviderSpecificSettingsImpl struct { + sharedDiskReplicationProviderSpecificSettings BaseSharedDiskReplicationProviderSpecificSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawSharedDiskReplicationProviderSpecificSettingsImpl) SharedDiskReplicationProviderSpecificSettings() BaseSharedDiskReplicationProviderSpecificSettingsImpl { + return s.sharedDiskReplicationProviderSpecificSettings +} + +func UnmarshalSharedDiskReplicationProviderSpecificSettingsImplementation(input []byte) (SharedDiskReplicationProviderSpecificSettings, 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 SharedDiskReplicationProviderSpecificSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2ASharedDiskReplicationDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ASharedDiskReplicationDetails: %+v", err) + } + return out, nil + } + + var parent BaseSharedDiskReplicationProviderSpecificSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSharedDiskReplicationProviderSpecificSettingsImpl: %+v", err) + } + + return RawSharedDiskReplicationProviderSpecificSettingsImpl{ + sharedDiskReplicationProviderSpecificSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/predicates.go new file mode 100644 index 00000000000..3a3afdd7e35 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/predicates.go @@ -0,0 +1,27 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectionClusterOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ReplicationProtectionClusterOperationPredicate) Matches(input ReplicationProtectionCluster) 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/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/version.go new file mode 100644 index 00000000000..49aae7c80ca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionclusters/version.go @@ -0,0 +1,10 @@ +package replicationprotectionclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationprotectionclusters/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/README.md new file mode 100644 index 00000000000..b1c314916dd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/README.md @@ -0,0 +1,133 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings` Documentation + +The `replicationprotectioncontainermappings` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings" +``` + + +### Client Initialization + +```go +client := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Create` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionContainerMappingName") + +payload := replicationprotectioncontainermappings.CreateProtectionContainerMappingInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Delete` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionContainerMappingName") + +payload := replicationprotectioncontainermappings.RemoveProtectionContainerMappingInput{ + // ... +} + + +if err := client.DeleteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Get` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionContainerMappingName") + +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: `ReplicationProtectionContainerMappingsClient.List` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// 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: `ReplicationProtectionContainerMappingsClient.ListByReplicationProtectionContainers` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +// alternatively `client.ListByReplicationProtectionContainers(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectionContainersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Purge` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionContainerMappingName") + +if err := client.PurgeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainerMappingsClient.Update` + +```go +ctx := context.TODO() +id := replicationprotectioncontainermappings.NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionContainerMappingName") + +payload := replicationprotectioncontainermappings.UpdateProtectionContainerMappingInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/client.go new file mode 100644 index 00000000000..4fe661f7f6f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/client.go @@ -0,0 +1,26 @@ +package replicationprotectioncontainermappings + +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 ReplicationProtectionContainerMappingsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectionContainerMappingsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectionContainerMappingsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationprotectioncontainermappings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectionContainerMappingsClient: %+v", err) + } + + return &ReplicationProtectionContainerMappingsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/constants.go new file mode 100644 index 00000000000..59286568ec1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/constants.go @@ -0,0 +1,133 @@ +package replicationprotectioncontainermappings + +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 AgentAutoUpdateStatus string + +const ( + AgentAutoUpdateStatusDisabled AgentAutoUpdateStatus = "Disabled" + AgentAutoUpdateStatusEnabled AgentAutoUpdateStatus = "Enabled" +) + +func PossibleValuesForAgentAutoUpdateStatus() []string { + return []string{ + string(AgentAutoUpdateStatusDisabled), + string(AgentAutoUpdateStatusEnabled), + } +} + +func (s *AgentAutoUpdateStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentAutoUpdateStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentAutoUpdateStatus(input string) (*AgentAutoUpdateStatus, error) { + vals := map[string]AgentAutoUpdateStatus{ + "disabled": AgentAutoUpdateStatusDisabled, + "enabled": AgentAutoUpdateStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentAutoUpdateStatus(input) + return &out, nil +} + +type AutomationAccountAuthenticationType string + +const ( + AutomationAccountAuthenticationTypeRunAsAccount AutomationAccountAuthenticationType = "RunAsAccount" + AutomationAccountAuthenticationTypeSystemAssignedIdentity AutomationAccountAuthenticationType = "SystemAssignedIdentity" +) + +func PossibleValuesForAutomationAccountAuthenticationType() []string { + return []string{ + string(AutomationAccountAuthenticationTypeRunAsAccount), + string(AutomationAccountAuthenticationTypeSystemAssignedIdentity), + } +} + +func (s *AutomationAccountAuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutomationAccountAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutomationAccountAuthenticationType(input string) (*AutomationAccountAuthenticationType, error) { + vals := map[string]AutomationAccountAuthenticationType{ + "runasaccount": AutomationAccountAuthenticationTypeRunAsAccount, + "systemassignedidentity": AutomationAccountAuthenticationTypeSystemAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutomationAccountAuthenticationType(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..61b19e9b5bb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer.go @@ -0,0 +1,148 @@ +package replicationprotectioncontainermappings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectionContainerId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..054eecca438 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationprotectioncontainermappings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping.go new file mode 100644 index 00000000000..2b2e19aec67 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping.go @@ -0,0 +1,157 @@ +package replicationprotectioncontainermappings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectionContainerMappingId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionContainerMappingId{} + +// ReplicationProtectionContainerMappingId is a struct representing the Resource ID for a Replication Protection Container Mapping +type ReplicationProtectionContainerMappingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectionContainerMappingName string +} + +// NewReplicationProtectionContainerMappingID returns a new ReplicationProtectionContainerMappingId struct +func NewReplicationProtectionContainerMappingID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectionContainerMappingName string) ReplicationProtectionContainerMappingId { + return ReplicationProtectionContainerMappingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectionContainerMappingName: replicationProtectionContainerMappingName, + } +} + +// ParseReplicationProtectionContainerMappingID parses 'input' into a ReplicationProtectionContainerMappingId +func ParseReplicationProtectionContainerMappingID(input string) (*ReplicationProtectionContainerMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerMappingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerMappingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerMappingIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerMappingId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerMappingIDInsensitively(input string) (*ReplicationProtectionContainerMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerMappingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerMappingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerMappingId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectionContainerMappingName, ok = input.Parsed["replicationProtectionContainerMappingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerMappingName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerMappingID checks that 'input' can be parsed as a Replication Protection Container Mapping ID +func ValidateReplicationProtectionContainerMappingID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectionContainerMappingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container Mapping ID +func (id ReplicationProtectionContainerMappingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectionContainerMappings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectionContainerMappingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container Mapping ID +func (id ReplicationProtectionContainerMappingId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectionContainerMappings", "replicationProtectionContainerMappings", "replicationProtectionContainerMappings"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerMappingName", "replicationProtectionContainerMappingName"), + } +} + +// String returns a human-readable description of this Replication Protection Container Mapping ID +func (id ReplicationProtectionContainerMappingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protection Container Mapping Name: %q", id.ReplicationProtectionContainerMappingName), + } + return fmt.Sprintf("Replication Protection Container Mapping (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping_test.go new file mode 100644 index 00000000000..3da16c9dc30 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_replicationprotectioncontainermapping_test.go @@ -0,0 +1,417 @@ +package replicationprotectioncontainermappings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectionContainerMappingId{} + +func TestNewReplicationProtectionContainerMappingID(t *testing.T) { + id := NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionContainerMappingName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectionContainerMappingName != "replicationProtectionContainerMappingName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerMappingName'", id.ReplicationProtectionContainerMappingName, "replicationProtectionContainerMappingName") + } +} + +func TestFormatReplicationProtectionContainerMappingID(t *testing.T) { + actual := NewReplicationProtectionContainerMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectionContainerMappingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionContainerMappings/replicationProtectionContainerMappingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerMappingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerMappingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionContainerMappings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionContainerMappings/replicationProtectionContainerMappingName", + Expected: &ReplicationProtectionContainerMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionContainerMappingName: "replicationProtectionContainerMappingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionContainerMappings/replicationProtectionContainerMappingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerMappingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionContainerMappingName != v.Expected.ReplicationProtectionContainerMappingName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerMappingName", v.Expected.ReplicationProtectionContainerMappingName, actual.ReplicationProtectionContainerMappingName) + } + + } +} + +func TestParseReplicationProtectionContainerMappingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerMappingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionContainerMappings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionContainerMappings/replicationProtectionContainerMappingName", + Expected: &ReplicationProtectionContainerMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectionContainerMappingName: "replicationProtectionContainerMappingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectionContainerMappings/replicationProtectionContainerMappingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgS/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgNaMe", + Expected: &ReplicationProtectionContainerMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectionContainerMappingName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgS/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRmApPiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerMappingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectionContainerMappingName != v.Expected.ReplicationProtectionContainerMappingName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerMappingName", v.Expected.ReplicationProtectionContainerMappingName, actual.ReplicationProtectionContainerMappingName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerMappingId(t *testing.T) { + segments := ReplicationProtectionContainerMappingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerMappingId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_vault.go new file mode 100644 index 00000000000..732e128c07b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_vault.go @@ -0,0 +1,130 @@ +package replicationprotectioncontainermappings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_vault_test.go new file mode 100644 index 00000000000..5d5304ccb76 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationprotectioncontainermappings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_create.go new file mode 100644 index 00000000000..48f9d495b34 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_create.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ProtectionContainerMapping +} + +// Create ... +func (c ReplicationProtectionContainerMappingsClient) Create(ctx context.Context, id ReplicationProtectionContainerMappingId, input CreateProtectionContainerMappingInput) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationProtectionContainerMappingsClient) CreateThenPoll(ctx context.Context, id ReplicationProtectionContainerMappingId, input CreateProtectionContainerMappingInput) 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/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_delete.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_delete.go new file mode 100644 index 00000000000..a7da6f7e3e3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_delete.go @@ -0,0 +1,74 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 ReplicationProtectionContainerMappingsClient) Delete(ctx context.Context, id ReplicationProtectionContainerMappingId, input RemoveProtectionContainerMappingInput) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.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 ReplicationProtectionContainerMappingsClient) DeleteThenPoll(ctx context.Context, id ReplicationProtectionContainerMappingId, input RemoveProtectionContainerMappingInput) error { + result, err := c.Delete(ctx, id, input) + 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/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_get.go new file mode 100644 index 00000000000..31623992dab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_get.go @@ -0,0 +1,53 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ProtectionContainerMapping +} + +// Get ... +func (c ReplicationProtectionContainerMappingsClient) Get(ctx context.Context, id ReplicationProtectionContainerMappingId) (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 ProtectionContainerMapping + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_list.go new file mode 100644 index 00000000000..95cb2a96220 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_list.go @@ -0,0 +1,105 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ProtectionContainerMapping +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectionContainerMapping +} + +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 ReplicationProtectionContainerMappingsClient) List(ctx context.Context, id VaultId) (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/replicationProtectionContainerMappings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProtectionContainerMapping `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 ReplicationProtectionContainerMappingsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ProtectionContainerMappingOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionContainerMappingsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate ProtectionContainerMappingOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ProtectionContainerMapping, 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/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_listbyreplicationprotectioncontainers.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_listbyreplicationprotectioncontainers.go new file mode 100644 index 00000000000..1e171e16a67 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_listbyreplicationprotectioncontainers.go @@ -0,0 +1,105 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationProtectionContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProtectionContainerMapping +} + +type ListByReplicationProtectionContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectionContainerMapping +} + +type ListByReplicationProtectionContainersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectionContainersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectionContainers ... +func (c ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainers(ctx context.Context, id ReplicationProtectionContainerId) (result ListByReplicationProtectionContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationProtectionContainersCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectionContainerMappings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProtectionContainerMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectionContainersComplete retrieves all the results into a single object +func (c ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersComplete(ctx context.Context, id ReplicationProtectionContainerId) (ListByReplicationProtectionContainersCompleteResult, error) { + return c.ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx, id, ProtectionContainerMappingOperationPredicate{}) +} + +// ListByReplicationProtectionContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectionContainerId, predicate ProtectionContainerMappingOperationPredicate) (result ListByReplicationProtectionContainersCompleteResult, err error) { + items := make([]ProtectionContainerMapping, 0) + + resp, err := c.ListByReplicationProtectionContainers(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 = ListByReplicationProtectionContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_purge.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_purge.go new file mode 100644 index 00000000000..fecbca3b41b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_purge.go @@ -0,0 +1,70 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c ReplicationProtectionContainerMappingsClient) Purge(ctx context.Context, id ReplicationProtectionContainerMappingId) (result PurgeOperationResponse, 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 +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c ReplicationProtectionContainerMappingsClient) PurgeThenPoll(ctx context.Context, id ReplicationProtectionContainerMappingId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_update.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_update.go new file mode 100644 index 00000000000..6a2852dda40 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/method_update.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainermappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ProtectionContainerMapping +} + +// Update ... +func (c ReplicationProtectionContainerMappingsClient) Update(ctx context.Context, id ReplicationProtectionContainerMappingId, input UpdateProtectionContainerMappingInput) (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 ReplicationProtectionContainerMappingsClient) UpdateThenPoll(ctx context.Context, id ReplicationProtectionContainerMappingId, input UpdateProtectionContainerMappingInput) 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/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_a2acontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_a2acontainermappinginput.go new file mode 100644 index 00000000000..520decdc12b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_a2acontainermappinginput.go @@ -0,0 +1,52 @@ +package replicationprotectioncontainermappings + +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 _ ReplicationProviderSpecificContainerMappingInput = A2AContainerMappingInput{} + +type A2AContainerMappingInput struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + + // Fields inherited from ReplicationProviderSpecificContainerMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AContainerMappingInput) ReplicationProviderSpecificContainerMappingInput() BaseReplicationProviderSpecificContainerMappingInputImpl { + return BaseReplicationProviderSpecificContainerMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AContainerMappingInput{} + +func (s A2AContainerMappingInput) MarshalJSON() ([]byte, error) { + type wrapper A2AContainerMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AContainerMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AContainerMappingInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AContainerMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_a2aprotectioncontainermappingdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_a2aprotectioncontainermappingdetails.go new file mode 100644 index 00000000000..f8d56c9abca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_a2aprotectioncontainermappingdetails.go @@ -0,0 +1,54 @@ +package replicationprotectioncontainermappings + +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 _ ProtectionContainerMappingProviderSpecificDetails = A2AProtectionContainerMappingDetails{} + +type A2AProtectionContainerMappingDetails struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + JobScheduleName *string `json:"jobScheduleName,omitempty"` + ScheduleName *string `json:"scheduleName,omitempty"` + + // Fields inherited from ProtectionContainerMappingProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s A2AProtectionContainerMappingDetails) ProtectionContainerMappingProviderSpecificDetails() BaseProtectionContainerMappingProviderSpecificDetailsImpl { + return BaseProtectionContainerMappingProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AProtectionContainerMappingDetails{} + +func (s A2AProtectionContainerMappingDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AProtectionContainerMappingDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AProtectionContainerMappingDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AProtectionContainerMappingDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AProtectionContainerMappingDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_a2aupdatecontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_a2aupdatecontainermappinginput.go new file mode 100644 index 00000000000..7eca6e5966e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_a2aupdatecontainermappinginput.go @@ -0,0 +1,52 @@ +package replicationprotectioncontainermappings + +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 _ ReplicationProviderSpecificUpdateContainerMappingInput = A2AUpdateContainerMappingInput{} + +type A2AUpdateContainerMappingInput struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + + // Fields inherited from ReplicationProviderSpecificUpdateContainerMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AUpdateContainerMappingInput) ReplicationProviderSpecificUpdateContainerMappingInput() BaseReplicationProviderSpecificUpdateContainerMappingInputImpl { + return BaseReplicationProviderSpecificUpdateContainerMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AUpdateContainerMappingInput{} + +func (s A2AUpdateContainerMappingInput) MarshalJSON() ([]byte, error) { + type wrapper A2AUpdateContainerMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AUpdateContainerMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AUpdateContainerMappingInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AUpdateContainerMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginput.go new file mode 100644 index 00000000000..49e1a32d873 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateProtectionContainerMappingInput struct { + Properties *CreateProtectionContainerMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginputproperties.go new file mode 100644 index 00000000000..ad0529d2f58 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_createprotectioncontainermappinginputproperties.go @@ -0,0 +1,45 @@ +package replicationprotectioncontainermappings + +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 CreateProtectionContainerMappingInputProperties struct { + PolicyId *string `json:"policyId,omitempty"` + ProviderSpecificInput ReplicationProviderSpecificContainerMappingInput `json:"providerSpecificInput"` + TargetProtectionContainerId *string `json:"targetProtectionContainerId,omitempty"` +} + +var _ json.Unmarshaler = &CreateProtectionContainerMappingInputProperties{} + +func (s *CreateProtectionContainerMappingInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + PolicyId *string `json:"policyId,omitempty"` + TargetProtectionContainerId *string `json:"targetProtectionContainerId,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.PolicyId = decoded.PolicyId + s.TargetProtectionContainerId = decoded.TargetProtectionContainerId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateProtectionContainerMappingInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + impl, err := UnmarshalReplicationProviderSpecificContainerMappingInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificInput' for 'CreateProtectionContainerMappingInputProperties': %+v", err) + } + s.ProviderSpecificInput = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_healtherror.go new file mode 100644 index 00000000000..a4c7339daba --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationprotectioncontainermappings + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_inmagercmprotectioncontainermappingdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_inmagercmprotectioncontainermappingdetails.go new file mode 100644 index 00000000000..1b6791491b6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_inmagercmprotectioncontainermappingdetails.go @@ -0,0 +1,50 @@ +package replicationprotectioncontainermappings + +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 _ ProtectionContainerMappingProviderSpecificDetails = InMageRcmProtectionContainerMappingDetails{} + +type InMageRcmProtectionContainerMappingDetails struct { + EnableAgentAutoUpgrade *string `json:"enableAgentAutoUpgrade,omitempty"` + + // Fields inherited from ProtectionContainerMappingProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmProtectionContainerMappingDetails) ProtectionContainerMappingProviderSpecificDetails() BaseProtectionContainerMappingProviderSpecificDetailsImpl { + return BaseProtectionContainerMappingProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmProtectionContainerMappingDetails{} + +func (s InMageRcmProtectionContainerMappingDetails) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmProtectionContainerMappingDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmProtectionContainerMappingDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmProtectionContainerMappingDetails: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmProtectionContainerMappingDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_inmagercmupdatecontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_inmagercmupdatecontainermappinginput.go new file mode 100644 index 00000000000..39728993aec --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_inmagercmupdatecontainermappinginput.go @@ -0,0 +1,50 @@ +package replicationprotectioncontainermappings + +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 _ ReplicationProviderSpecificUpdateContainerMappingInput = InMageRcmUpdateContainerMappingInput{} + +type InMageRcmUpdateContainerMappingInput struct { + EnableAgentAutoUpgrade string `json:"enableAgentAutoUpgrade"` + + // Fields inherited from ReplicationProviderSpecificUpdateContainerMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s InMageRcmUpdateContainerMappingInput) ReplicationProviderSpecificUpdateContainerMappingInput() BaseReplicationProviderSpecificUpdateContainerMappingInputImpl { + return BaseReplicationProviderSpecificUpdateContainerMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = InMageRcmUpdateContainerMappingInput{} + +func (s InMageRcmUpdateContainerMappingInput) MarshalJSON() ([]byte, error) { + type wrapper InMageRcmUpdateContainerMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling InMageRcmUpdateContainerMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling InMageRcmUpdateContainerMappingInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling InMageRcmUpdateContainerMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_innerhealtherror.go new file mode 100644 index 00000000000..20d411ae371 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationprotectioncontainermappings + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_protectioncontainermapping.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_protectioncontainermapping.go new file mode 100644 index 00000000000..6fcec0153e7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_protectioncontainermapping.go @@ -0,0 +1,12 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerMapping struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProtectionContainerMappingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_protectioncontainermappingproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_protectioncontainermappingproperties.go new file mode 100644 index 00000000000..04fd7e9d4b9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_protectioncontainermappingproperties.go @@ -0,0 +1,69 @@ +package replicationprotectioncontainermappings + +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 ProtectionContainerMappingProperties struct { + Health *string `json:"health,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProviderSpecificDetails ProtectionContainerMappingProviderSpecificDetails `json:"providerSpecificDetails"` + SourceFabricFriendlyName *string `json:"sourceFabricFriendlyName,omitempty"` + SourceProtectionContainerFriendlyName *string `json:"sourceProtectionContainerFriendlyName,omitempty"` + State *string `json:"state,omitempty"` + TargetFabricFriendlyName *string `json:"targetFabricFriendlyName,omitempty"` + TargetProtectionContainerFriendlyName *string `json:"targetProtectionContainerFriendlyName,omitempty"` + TargetProtectionContainerId *string `json:"targetProtectionContainerId,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionContainerMappingProperties{} + +func (s *ProtectionContainerMappingProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Health *string `json:"health,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + SourceFabricFriendlyName *string `json:"sourceFabricFriendlyName,omitempty"` + SourceProtectionContainerFriendlyName *string `json:"sourceProtectionContainerFriendlyName,omitempty"` + State *string `json:"state,omitempty"` + TargetFabricFriendlyName *string `json:"targetFabricFriendlyName,omitempty"` + TargetProtectionContainerFriendlyName *string `json:"targetProtectionContainerFriendlyName,omitempty"` + TargetProtectionContainerId *string `json:"targetProtectionContainerId,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Health = decoded.Health + s.HealthErrorDetails = decoded.HealthErrorDetails + s.PolicyFriendlyName = decoded.PolicyFriendlyName + s.PolicyId = decoded.PolicyId + s.SourceFabricFriendlyName = decoded.SourceFabricFriendlyName + s.SourceProtectionContainerFriendlyName = decoded.SourceProtectionContainerFriendlyName + s.State = decoded.State + s.TargetFabricFriendlyName = decoded.TargetFabricFriendlyName + s.TargetProtectionContainerFriendlyName = decoded.TargetProtectionContainerFriendlyName + s.TargetProtectionContainerId = decoded.TargetProtectionContainerId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionContainerMappingProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalProtectionContainerMappingProviderSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ProtectionContainerMappingProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_protectioncontainermappingproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_protectioncontainermappingproviderspecificdetails.go new file mode 100644 index 00000000000..219606477d7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_protectioncontainermappingproviderspecificdetails.go @@ -0,0 +1,91 @@ +package replicationprotectioncontainermappings + +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 ProtectionContainerMappingProviderSpecificDetails interface { + ProtectionContainerMappingProviderSpecificDetails() BaseProtectionContainerMappingProviderSpecificDetailsImpl +} + +var _ ProtectionContainerMappingProviderSpecificDetails = BaseProtectionContainerMappingProviderSpecificDetailsImpl{} + +type BaseProtectionContainerMappingProviderSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseProtectionContainerMappingProviderSpecificDetailsImpl) ProtectionContainerMappingProviderSpecificDetails() BaseProtectionContainerMappingProviderSpecificDetailsImpl { + return s +} + +var _ ProtectionContainerMappingProviderSpecificDetails = RawProtectionContainerMappingProviderSpecificDetailsImpl{} + +// RawProtectionContainerMappingProviderSpecificDetailsImpl 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 RawProtectionContainerMappingProviderSpecificDetailsImpl struct { + protectionContainerMappingProviderSpecificDetails BaseProtectionContainerMappingProviderSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawProtectionContainerMappingProviderSpecificDetailsImpl) ProtectionContainerMappingProviderSpecificDetails() BaseProtectionContainerMappingProviderSpecificDetailsImpl { + return s.protectionContainerMappingProviderSpecificDetails +} + +func UnmarshalProtectionContainerMappingProviderSpecificDetailsImplementation(input []byte) (ProtectionContainerMappingProviderSpecificDetails, 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 ProtectionContainerMappingProviderSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AProtectionContainerMappingDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AProtectionContainerMappingDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmProtectionContainerMappingDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmProtectionContainerMappingDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtProtectionContainerMappingDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtProtectionContainerMappingDetails: %+v", err) + } + return out, nil + } + + var parent BaseProtectionContainerMappingProviderSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProtectionContainerMappingProviderSpecificDetailsImpl: %+v", err) + } + + return RawProtectionContainerMappingProviderSpecificDetailsImpl{ + protectionContainerMappingProviderSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginput.go new file mode 100644 index 00000000000..ac6d64ca0d6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoveProtectionContainerMappingInput struct { + Properties *RemoveProtectionContainerMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginputproperties.go new file mode 100644 index 00000000000..cda0927d8cd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_removeprotectioncontainermappinginputproperties.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemoveProtectionContainerMappingInputProperties struct { + ProviderSpecificInput *ReplicationProviderContainerUnmappingInput `json:"providerSpecificInput,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_replicationprovidercontainerunmappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_replicationprovidercontainerunmappinginput.go new file mode 100644 index 00000000000..862047c52a1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_replicationprovidercontainerunmappinginput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProviderContainerUnmappingInput struct { + InstanceType *string `json:"instanceType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_replicationproviderspecificcontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_replicationproviderspecificcontainermappinginput.go new file mode 100644 index 00000000000..dfce897f5d0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_replicationproviderspecificcontainermappinginput.go @@ -0,0 +1,83 @@ +package replicationprotectioncontainermappings + +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 ReplicationProviderSpecificContainerMappingInput interface { + ReplicationProviderSpecificContainerMappingInput() BaseReplicationProviderSpecificContainerMappingInputImpl +} + +var _ ReplicationProviderSpecificContainerMappingInput = BaseReplicationProviderSpecificContainerMappingInputImpl{} + +type BaseReplicationProviderSpecificContainerMappingInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseReplicationProviderSpecificContainerMappingInputImpl) ReplicationProviderSpecificContainerMappingInput() BaseReplicationProviderSpecificContainerMappingInputImpl { + return s +} + +var _ ReplicationProviderSpecificContainerMappingInput = RawReplicationProviderSpecificContainerMappingInputImpl{} + +// RawReplicationProviderSpecificContainerMappingInputImpl 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 RawReplicationProviderSpecificContainerMappingInputImpl struct { + replicationProviderSpecificContainerMappingInput BaseReplicationProviderSpecificContainerMappingInputImpl + Type string + Values map[string]interface{} +} + +func (s RawReplicationProviderSpecificContainerMappingInputImpl) ReplicationProviderSpecificContainerMappingInput() BaseReplicationProviderSpecificContainerMappingInputImpl { + return s.replicationProviderSpecificContainerMappingInput +} + +func UnmarshalReplicationProviderSpecificContainerMappingInputImplementation(input []byte) (ReplicationProviderSpecificContainerMappingInput, 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 ReplicationProviderSpecificContainerMappingInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AContainerMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AContainerMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtContainerMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtContainerMappingInput: %+v", err) + } + return out, nil + } + + var parent BaseReplicationProviderSpecificContainerMappingInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseReplicationProviderSpecificContainerMappingInputImpl: %+v", err) + } + + return RawReplicationProviderSpecificContainerMappingInputImpl{ + replicationProviderSpecificContainerMappingInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_replicationproviderspecificupdatecontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_replicationproviderspecificupdatecontainermappinginput.go new file mode 100644 index 00000000000..b32cc5dc7c0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_replicationproviderspecificupdatecontainermappinginput.go @@ -0,0 +1,83 @@ +package replicationprotectioncontainermappings + +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 ReplicationProviderSpecificUpdateContainerMappingInput interface { + ReplicationProviderSpecificUpdateContainerMappingInput() BaseReplicationProviderSpecificUpdateContainerMappingInputImpl +} + +var _ ReplicationProviderSpecificUpdateContainerMappingInput = BaseReplicationProviderSpecificUpdateContainerMappingInputImpl{} + +type BaseReplicationProviderSpecificUpdateContainerMappingInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseReplicationProviderSpecificUpdateContainerMappingInputImpl) ReplicationProviderSpecificUpdateContainerMappingInput() BaseReplicationProviderSpecificUpdateContainerMappingInputImpl { + return s +} + +var _ ReplicationProviderSpecificUpdateContainerMappingInput = RawReplicationProviderSpecificUpdateContainerMappingInputImpl{} + +// RawReplicationProviderSpecificUpdateContainerMappingInputImpl 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 RawReplicationProviderSpecificUpdateContainerMappingInputImpl struct { + replicationProviderSpecificUpdateContainerMappingInput BaseReplicationProviderSpecificUpdateContainerMappingInputImpl + Type string + Values map[string]interface{} +} + +func (s RawReplicationProviderSpecificUpdateContainerMappingInputImpl) ReplicationProviderSpecificUpdateContainerMappingInput() BaseReplicationProviderSpecificUpdateContainerMappingInputImpl { + return s.replicationProviderSpecificUpdateContainerMappingInput +} + +func UnmarshalReplicationProviderSpecificUpdateContainerMappingInputImplementation(input []byte) (ReplicationProviderSpecificUpdateContainerMappingInput, 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 ReplicationProviderSpecificUpdateContainerMappingInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AUpdateContainerMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AUpdateContainerMappingInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out InMageRcmUpdateContainerMappingInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into InMageRcmUpdateContainerMappingInput: %+v", err) + } + return out, nil + } + + var parent BaseReplicationProviderSpecificUpdateContainerMappingInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseReplicationProviderSpecificUpdateContainerMappingInputImpl: %+v", err) + } + + return RawReplicationProviderSpecificUpdateContainerMappingInputImpl{ + replicationProviderSpecificUpdateContainerMappingInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginput.go new file mode 100644 index 00000000000..9c2d7bf172c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateProtectionContainerMappingInput struct { + Properties *UpdateProtectionContainerMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginputproperties.go new file mode 100644 index 00000000000..f68cab5cb26 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_updateprotectioncontainermappinginputproperties.go @@ -0,0 +1,33 @@ +package replicationprotectioncontainermappings + +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 UpdateProtectionContainerMappingInputProperties struct { + ProviderSpecificInput ReplicationProviderSpecificUpdateContainerMappingInput `json:"providerSpecificInput"` +} + +var _ json.Unmarshaler = &UpdateProtectionContainerMappingInputProperties{} + +func (s *UpdateProtectionContainerMappingInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling UpdateProtectionContainerMappingInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + impl, err := UnmarshalReplicationProviderSpecificUpdateContainerMappingInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificInput' for 'UpdateProtectionContainerMappingInputProperties': %+v", err) + } + s.ProviderSpecificInput = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_vmwarecbtcontainermappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_vmwarecbtcontainermappinginput.go new file mode 100644 index 00000000000..a7b44d461aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_vmwarecbtcontainermappinginput.go @@ -0,0 +1,55 @@ +package replicationprotectioncontainermappings + +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 _ ReplicationProviderSpecificContainerMappingInput = VMwareCbtContainerMappingInput{} + +type VMwareCbtContainerMappingInput struct { + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultUri *string `json:"keyVaultUri,omitempty"` + ServiceBusConnectionStringSecretName *string `json:"serviceBusConnectionStringSecretName,omitempty"` + StorageAccountId string `json:"storageAccountId"` + StorageAccountSasSecretName *string `json:"storageAccountSasSecretName,omitempty"` + TargetLocation string `json:"targetLocation"` + + // Fields inherited from ReplicationProviderSpecificContainerMappingInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtContainerMappingInput) ReplicationProviderSpecificContainerMappingInput() BaseReplicationProviderSpecificContainerMappingInputImpl { + return BaseReplicationProviderSpecificContainerMappingInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtContainerMappingInput{} + +func (s VMwareCbtContainerMappingInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtContainerMappingInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtContainerMappingInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtContainerMappingInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtContainerMappingInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_vmwarecbtprotectioncontainermappingdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_vmwarecbtprotectioncontainermappingdetails.go new file mode 100644 index 00000000000..0e4716ee72b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/model_vmwarecbtprotectioncontainermappingdetails.go @@ -0,0 +1,57 @@ +package replicationprotectioncontainermappings + +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 _ ProtectionContainerMappingProviderSpecificDetails = VMwareCbtProtectionContainerMappingDetails{} + +type VMwareCbtProtectionContainerMappingDetails struct { + ExcludedSkus *[]string `json:"excludedSkus,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultUri *string `json:"keyVaultUri,omitempty"` + RoleSizeToNicCountMap *map[string]int64 `json:"roleSizeToNicCountMap,omitempty"` + ServiceBusConnectionStringSecretName *string `json:"serviceBusConnectionStringSecretName,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + StorageAccountSasSecretName *string `json:"storageAccountSasSecretName,omitempty"` + TargetLocation *string `json:"targetLocation,omitempty"` + + // Fields inherited from ProtectionContainerMappingProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtProtectionContainerMappingDetails) ProtectionContainerMappingProviderSpecificDetails() BaseProtectionContainerMappingProviderSpecificDetailsImpl { + return BaseProtectionContainerMappingProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtProtectionContainerMappingDetails{} + +func (s VMwareCbtProtectionContainerMappingDetails) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtProtectionContainerMappingDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtProtectionContainerMappingDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtProtectionContainerMappingDetails: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtProtectionContainerMappingDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/predicates.go new file mode 100644 index 00000000000..c60ddcb4a31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/predicates.go @@ -0,0 +1,32 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerMappingOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectionContainerMappingOperationPredicate) Matches(input ProtectionContainerMapping) 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/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/version.go new file mode 100644 index 00000000000..62eb6a37ea9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainermappings/version.go @@ -0,0 +1,10 @@ +package replicationprotectioncontainermappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationprotectioncontainermappings/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/README.md new file mode 100644 index 00000000000..9489de4b358 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/README.md @@ -0,0 +1,150 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers` Documentation + +The `replicationprotectioncontainers` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers" +``` + + +### Client Initialization + +```go +client := replicationprotectioncontainers.NewReplicationProtectionContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectionContainersClient.Create` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +payload := replicationprotectioncontainers.CreateProtectionContainerInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.Delete` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.DiscoverProtectableItem` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +payload := replicationprotectioncontainers.DiscoverProtectableItemRequest{ + // ... +} + + +if err := client.DiscoverProtectableItemThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.Get` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +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: `ReplicationProtectionContainersClient.List` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// 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: `ReplicationProtectionContainersClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.SwitchClusterProtection` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +payload := replicationprotectioncontainers.SwitchClusterProtectionInput{ + // ... +} + + +if err := client.SwitchClusterProtectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationProtectionContainersClient.SwitchProtection` + +```go +ctx := context.TODO() +id := replicationprotectioncontainers.NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + +payload := replicationprotectioncontainers.SwitchProtectionInput{ + // ... +} + + +if err := client.SwitchProtectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/client.go new file mode 100644 index 00000000000..29eec428f7f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/client.go @@ -0,0 +1,26 @@ +package replicationprotectioncontainers + +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 ReplicationProtectionContainersClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectionContainersClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectionContainersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationprotectioncontainers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectionContainersClient: %+v", err) + } + + return &ReplicationProtectionContainersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_replicationfabric.go new file mode 100644 index 00000000000..3bd079512ad --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_replicationfabric.go @@ -0,0 +1,139 @@ +package replicationprotectioncontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationFabricId{}) +} + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_replicationfabric_test.go new file mode 100644 index 00000000000..4bf4be40c8e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationprotectioncontainers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_replicationprotectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_replicationprotectioncontainer.go new file mode 100644 index 00000000000..e5592319c54 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_replicationprotectioncontainer.go @@ -0,0 +1,148 @@ +package replicationprotectioncontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectionContainerId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +// ReplicationProtectionContainerId is a struct representing the Resource ID for a Replication Protection Container +type ReplicationProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string +} + +// NewReplicationProtectionContainerID returns a new ReplicationProtectionContainerId struct +func NewReplicationProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string) ReplicationProtectionContainerId { + return ReplicationProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + } +} + +// ParseReplicationProtectionContainerID parses 'input' into a ReplicationProtectionContainerId +func ParseReplicationProtectionContainerID(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionContainerIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionContainerIDInsensitively(input string) (*ReplicationProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionContainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionContainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + return nil +} + +// ValidateReplicationProtectionContainerID checks that 'input' can be parsed as a Replication Protection Container ID +func ValidateReplicationProtectionContainerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Container ID +func (id ReplicationProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Container ID +func (id ReplicationProtectionContainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + } +} + +// String returns a human-readable description of this Replication Protection Container ID +func (id ReplicationProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + } + return fmt.Sprintf("Replication Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_replicationprotectioncontainer_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_replicationprotectioncontainer_test.go new file mode 100644 index 00000000000..a91ca97cb10 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_replicationprotectioncontainer_test.go @@ -0,0 +1,372 @@ +package replicationprotectioncontainers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectionContainerId{} + +func TestNewReplicationProtectionContainerID(t *testing.T) { + id := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } +} + +func TestFormatReplicationProtectionContainerID(t *testing.T) { + actual := NewReplicationProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestParseReplicationProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Expected: &ReplicationProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionContainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + } +} + +func TestSegmentsForReplicationProtectionContainerId(t *testing.T) { + segments := ReplicationProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionContainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_vault.go new file mode 100644 index 00000000000..8bf89545d20 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_vault.go @@ -0,0 +1,130 @@ +package replicationprotectioncontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_vault_test.go new file mode 100644 index 00000000000..4d480e32c58 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationprotectioncontainers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_create.go new file mode 100644 index 00000000000..ceb6aa4ab31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_create.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ProtectionContainer +} + +// Create ... +func (c ReplicationProtectionContainersClient) Create(ctx context.Context, id ReplicationProtectionContainerId, input CreateProtectionContainerInput) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationProtectionContainersClient) CreateThenPoll(ctx context.Context, id ReplicationProtectionContainerId, input CreateProtectionContainerInput) 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/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_delete.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_delete.go new file mode 100644 index 00000000000..63ac30675e0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_delete.go @@ -0,0 +1,70 @@ +package replicationprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 ReplicationProtectionContainersClient) Delete(ctx context.Context, id ReplicationProtectionContainerId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.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 ReplicationProtectionContainersClient) DeleteThenPoll(ctx context.Context, id ReplicationProtectionContainerId) 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/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_discoverprotectableitem.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_discoverprotectableitem.go new file mode 100644 index 00000000000..6a65eda5d16 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_discoverprotectableitem.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoverProtectableItemOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainer +} + +// DiscoverProtectableItem ... +func (c ReplicationProtectionContainersClient) DiscoverProtectableItem(ctx context.Context, id ReplicationProtectionContainerId, input DiscoverProtectableItemRequest) (result DiscoverProtectableItemOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/discoverProtectableItem", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DiscoverProtectableItemThenPoll performs DiscoverProtectableItem then polls until it's completed +func (c ReplicationProtectionContainersClient) DiscoverProtectableItemThenPoll(ctx context.Context, id ReplicationProtectionContainerId, input DiscoverProtectableItemRequest) error { + result, err := c.DiscoverProtectableItem(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DiscoverProtectableItem: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DiscoverProtectableItem: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_get.go new file mode 100644 index 00000000000..76f18d1e4d0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_get.go @@ -0,0 +1,53 @@ +package replicationprotectioncontainers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ProtectionContainer +} + +// Get ... +func (c ReplicationProtectionContainersClient) Get(ctx context.Context, id ReplicationProtectionContainerId) (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 ProtectionContainer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_list.go new file mode 100644 index 00000000000..d678bf5102a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_list.go @@ -0,0 +1,105 @@ +package replicationprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ProtectionContainer +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectionContainer +} + +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 ReplicationProtectionContainersClient) List(ctx context.Context, id VaultId) (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/replicationProtectionContainers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProtectionContainer `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 ReplicationProtectionContainersClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ProtectionContainerOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionContainersClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate ProtectionContainerOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ProtectionContainer, 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/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..d870a7c81fd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_listbyreplicationfabrics.go @@ -0,0 +1,105 @@ +package replicationprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProtectionContainer +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProtectionContainer +} + +type ListByReplicationFabricsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationFabricsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationFabrics ... +func (c ReplicationProtectionContainersClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationFabricsCustomPager{}, + Path: fmt.Sprintf("%s/replicationProtectionContainers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProtectionContainer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationProtectionContainersClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, ProtectionContainerOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionContainersClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate ProtectionContainerOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]ProtectionContainer, 0) + + resp, err := c.ListByReplicationFabrics(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 = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_switchclusterprotection.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_switchclusterprotection.go new file mode 100644 index 00000000000..f8e1e9bde75 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_switchclusterprotection.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchClusterProtectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainer +} + +// SwitchClusterProtection ... +func (c ReplicationProtectionContainersClient) SwitchClusterProtection(ctx context.Context, id ReplicationProtectionContainerId, input SwitchClusterProtectionInput) (result SwitchClusterProtectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/switchClusterProtection", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SwitchClusterProtectionThenPoll performs SwitchClusterProtection then polls until it's completed +func (c ReplicationProtectionContainersClient) SwitchClusterProtectionThenPoll(ctx context.Context, id ReplicationProtectionContainerId, input SwitchClusterProtectionInput) error { + result, err := c.SwitchClusterProtection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwitchClusterProtection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwitchClusterProtection: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_switchprotection.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_switchprotection.go new file mode 100644 index 00000000000..a9b935c76c1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/method_switchprotection.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchProtectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ProtectionContainer +} + +// SwitchProtection ... +func (c ReplicationProtectionContainersClient) SwitchProtection(ctx context.Context, id ReplicationProtectionContainerId, input SwitchProtectionInput) (result SwitchProtectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/switchprotection", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SwitchProtectionThenPoll performs SwitchProtection then polls until it's completed +func (c ReplicationProtectionContainersClient) SwitchProtectionThenPoll(ctx context.Context, id ReplicationProtectionContainerId, input SwitchProtectionInput) error { + result, err := c.SwitchProtection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwitchProtection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwitchProtection: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2acontainercreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2acontainercreationinput.go new file mode 100644 index 00000000000..f119b15f58d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2acontainercreationinput.go @@ -0,0 +1,49 @@ +package replicationprotectioncontainers + +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 _ ReplicationProviderSpecificContainerCreationInput = A2AContainerCreationInput{} + +type A2AContainerCreationInput struct { + + // Fields inherited from ReplicationProviderSpecificContainerCreationInput + + InstanceType string `json:"instanceType"` +} + +func (s A2AContainerCreationInput) ReplicationProviderSpecificContainerCreationInput() BaseReplicationProviderSpecificContainerCreationInputImpl { + return BaseReplicationProviderSpecificContainerCreationInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AContainerCreationInput{} + +func (s A2AContainerCreationInput) MarshalJSON() ([]byte, error) { + type wrapper A2AContainerCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AContainerCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AContainerCreationInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AContainerCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2acrossclustermigrationcontainercreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2acrossclustermigrationcontainercreationinput.go new file mode 100644 index 00000000000..8f67cf738e5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2acrossclustermigrationcontainercreationinput.go @@ -0,0 +1,49 @@ +package replicationprotectioncontainers + +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 _ ReplicationProviderSpecificContainerCreationInput = A2ACrossClusterMigrationContainerCreationInput{} + +type A2ACrossClusterMigrationContainerCreationInput struct { + + // Fields inherited from ReplicationProviderSpecificContainerCreationInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ACrossClusterMigrationContainerCreationInput) ReplicationProviderSpecificContainerCreationInput() BaseReplicationProviderSpecificContainerCreationInputImpl { + return BaseReplicationProviderSpecificContainerCreationInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ACrossClusterMigrationContainerCreationInput{} + +func (s A2ACrossClusterMigrationContainerCreationInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACrossClusterMigrationContainerCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACrossClusterMigrationContainerCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACrossClusterMigrationContainerCreationInput: %+v", err) + } + + decoded["instanceType"] = "A2ACrossClusterMigration" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACrossClusterMigrationContainerCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2aprotecteditemdetail.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2aprotecteditemdetail.go new file mode 100644 index 00000000000..0bd00cf3819 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2aprotecteditemdetail.go @@ -0,0 +1,17 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AProtectedItemDetail struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryBootDiagStorageAccountId *string `json:"recoveryBootDiagStorageAccountId,omitempty"` + RecoveryCapacityReservationGroupId *string `json:"recoveryCapacityReservationGroupId,omitempty"` + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryVirtualMachineScaleSetId *string `json:"recoveryVirtualMachineScaleSetId,omitempty"` + ReplicationProtectedItemName *string `json:"replicationProtectedItemName,omitempty"` + VMManagedDisks *[]A2AVMManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2aswitchclusterprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2aswitchclusterprotectioninput.go new file mode 100644 index 00000000000..162f36c45b2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2aswitchclusterprotectioninput.go @@ -0,0 +1,52 @@ +package replicationprotectioncontainers + +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 _ SwitchClusterProtectionProviderSpecificInput = A2ASwitchClusterProtectionInput{} + +type A2ASwitchClusterProtectionInput struct { + PolicyId *string `json:"policyId,omitempty"` + ProtectedItemsDetail *[]A2AProtectedItemDetail `json:"protectedItemsDetail,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + + // Fields inherited from SwitchClusterProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ASwitchClusterProtectionInput) SwitchClusterProtectionProviderSpecificInput() BaseSwitchClusterProtectionProviderSpecificInputImpl { + return BaseSwitchClusterProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ASwitchClusterProtectionInput{} + +func (s A2ASwitchClusterProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper A2ASwitchClusterProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ASwitchClusterProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ASwitchClusterProtectionInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ASwitchClusterProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2aswitchprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2aswitchprotectioninput.go new file mode 100644 index 00000000000..fc86ae07dcd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2aswitchprotectioninput.go @@ -0,0 +1,62 @@ +package replicationprotectioncontainers + +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 _ SwitchProtectionProviderSpecificInput = A2ASwitchProtectionInput{} + +type A2ASwitchProtectionInput struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryBootDiagStorageAccountId *string `json:"recoveryBootDiagStorageAccountId,omitempty"` + RecoveryCapacityReservationGroupId *string `json:"recoveryCapacityReservationGroupId,omitempty"` + RecoveryCloudServiceId *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryContainerId *string `json:"recoveryContainerId,omitempty"` + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryVirtualMachineScaleSetId *string `json:"recoveryVirtualMachineScaleSetId,omitempty"` + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AVMManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from SwitchProtectionProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s A2ASwitchProtectionInput) SwitchProtectionProviderSpecificInput() BaseSwitchProtectionProviderSpecificInputImpl { + return BaseSwitchProtectionProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ASwitchProtectionInput{} + +func (s A2ASwitchProtectionInput) MarshalJSON() ([]byte, error) { + type wrapper A2ASwitchProtectionInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ASwitchProtectionInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ASwitchProtectionInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ASwitchProtectionInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2avmdiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2avmdiskinputdetails.go new file mode 100644 index 00000000000..1e0784c90fc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2avmdiskinputdetails.go @@ -0,0 +1,10 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMDiskInputDetails struct { + DiskUri string `json:"diskUri"` + PrimaryStagingAzureStorageAccountId string `json:"primaryStagingAzureStorageAccountId"` + RecoveryAzureStorageAccountId string `json:"recoveryAzureStorageAccountId"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2avmmanageddiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2avmmanageddiskinputdetails.go new file mode 100644 index 00000000000..6c0c988393d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_a2avmmanageddiskinputdetails.go @@ -0,0 +1,14 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type A2AVMManagedDiskInputDetails struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + DiskId string `json:"diskId"` + PrimaryStagingAzureStorageAccountId string `json:"primaryStagingAzureStorageAccountId"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryResourceGroupId string `json:"recoveryResourceGroupId"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_createprotectioncontainerinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_createprotectioncontainerinput.go new file mode 100644 index 00000000000..55175403c81 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_createprotectioncontainerinput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateProtectionContainerInput struct { + Properties *CreateProtectionContainerInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_createprotectioncontainerinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_createprotectioncontainerinputproperties.go new file mode 100644 index 00000000000..48d608a76f0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_createprotectioncontainerinputproperties.go @@ -0,0 +1,42 @@ +package replicationprotectioncontainers + +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 CreateProtectionContainerInputProperties struct { + ProviderSpecificInput *[]ReplicationProviderSpecificContainerCreationInput `json:"providerSpecificInput,omitempty"` +} + +var _ json.Unmarshaler = &CreateProtectionContainerInputProperties{} + +func (s *CreateProtectionContainerInputProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateProtectionContainerInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificInput into list []json.RawMessage: %+v", err) + } + + output := make([]ReplicationProviderSpecificContainerCreationInput, 0) + for i, val := range listTemp { + impl, err := UnmarshalReplicationProviderSpecificContainerCreationInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificInput' for 'CreateProtectionContainerInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificInput = &output + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_discoverprotectableitemrequest.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_discoverprotectableitemrequest.go new file mode 100644 index 00000000000..ceca9005e59 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_discoverprotectableitemrequest.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoverProtectableItemRequest struct { + Properties *DiscoverProtectableItemRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_discoverprotectableitemrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_discoverprotectableitemrequestproperties.go new file mode 100644 index 00000000000..fee5502a3c7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_discoverprotectableitemrequestproperties.go @@ -0,0 +1,10 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoverProtectableItemRequestProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + OsType *string `json:"osType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_diskencryptioninfo.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_diskencryptioninfo.go new file mode 100644 index 00000000000..997e7018bf6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_diskencryptioninfo.go @@ -0,0 +1,9 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionInfo struct { + DiskEncryptionKeyInfo *DiskEncryptionKeyInfo `json:"diskEncryptionKeyInfo,omitempty"` + KeyEncryptionKeyInfo *KeyEncryptionKeyInfo `json:"keyEncryptionKeyInfo,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_diskencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_diskencryptionkeyinfo.go new file mode 100644 index 00000000000..e67e3239790 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_diskencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionKeyInfo struct { + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_keyencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_keyencryptionkeyinfo.go new file mode 100644 index 00000000000..e5eb025e741 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_keyencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyEncryptionKeyInfo struct { + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_protectioncontainer.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_protectioncontainer.go new file mode 100644 index 00000000000..0236469ade2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_protectioncontainer.go @@ -0,0 +1,12 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainer struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProtectionContainerProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_protectioncontainerfabricspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_protectioncontainerfabricspecificdetails.go new file mode 100644 index 00000000000..ccda06f411a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_protectioncontainerfabricspecificdetails.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerFabricSpecificDetails struct { + InstanceType *string `json:"instanceType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_protectioncontainerproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_protectioncontainerproperties.go new file mode 100644 index 00000000000..baa48fb4dcd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_protectioncontainerproperties.go @@ -0,0 +1,14 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerProperties struct { + FabricFriendlyName *string `json:"fabricFriendlyName,omitempty"` + FabricSpecificDetails *ProtectionContainerFabricSpecificDetails `json:"fabricSpecificDetails,omitempty"` + FabricType *string `json:"fabricType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + PairingStatus *string `json:"pairingStatus,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + Role *string `json:"role,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_replicationproviderspecificcontainercreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_replicationproviderspecificcontainercreationinput.go new file mode 100644 index 00000000000..584ed7078c6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_replicationproviderspecificcontainercreationinput.go @@ -0,0 +1,91 @@ +package replicationprotectioncontainers + +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 ReplicationProviderSpecificContainerCreationInput interface { + ReplicationProviderSpecificContainerCreationInput() BaseReplicationProviderSpecificContainerCreationInputImpl +} + +var _ ReplicationProviderSpecificContainerCreationInput = BaseReplicationProviderSpecificContainerCreationInputImpl{} + +type BaseReplicationProviderSpecificContainerCreationInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseReplicationProviderSpecificContainerCreationInputImpl) ReplicationProviderSpecificContainerCreationInput() BaseReplicationProviderSpecificContainerCreationInputImpl { + return s +} + +var _ ReplicationProviderSpecificContainerCreationInput = RawReplicationProviderSpecificContainerCreationInputImpl{} + +// RawReplicationProviderSpecificContainerCreationInputImpl 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 RawReplicationProviderSpecificContainerCreationInputImpl struct { + replicationProviderSpecificContainerCreationInput BaseReplicationProviderSpecificContainerCreationInputImpl + Type string + Values map[string]interface{} +} + +func (s RawReplicationProviderSpecificContainerCreationInputImpl) ReplicationProviderSpecificContainerCreationInput() BaseReplicationProviderSpecificContainerCreationInputImpl { + return s.replicationProviderSpecificContainerCreationInput +} + +func UnmarshalReplicationProviderSpecificContainerCreationInputImplementation(input []byte) (ReplicationProviderSpecificContainerCreationInput, 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 ReplicationProviderSpecificContainerCreationInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AContainerCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AContainerCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "A2ACrossClusterMigration") { + var out A2ACrossClusterMigrationContainerCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACrossClusterMigrationContainerCreationInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMwareCbt") { + var out VMwareCbtContainerCreationInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VMwareCbtContainerCreationInput: %+v", err) + } + return out, nil + } + + var parent BaseReplicationProviderSpecificContainerCreationInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseReplicationProviderSpecificContainerCreationInputImpl: %+v", err) + } + + return RawReplicationProviderSpecificContainerCreationInputImpl{ + replicationProviderSpecificContainerCreationInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchclusterprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchclusterprotectioninput.go new file mode 100644 index 00000000000..7e8c500b452 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchclusterprotectioninput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchClusterProtectionInput struct { + Properties *SwitchClusterProtectionInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchclusterprotectioninputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchclusterprotectioninputproperties.go new file mode 100644 index 00000000000..4a8c6eb5b38 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchclusterprotectioninputproperties.go @@ -0,0 +1,42 @@ +package replicationprotectioncontainers + +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 SwitchClusterProtectionInputProperties struct { + ProviderSpecificDetails SwitchClusterProtectionProviderSpecificInput `json:"providerSpecificDetails"` + ReplicationProtectionClusterName *string `json:"replicationProtectionClusterName,omitempty"` +} + +var _ json.Unmarshaler = &SwitchClusterProtectionInputProperties{} + +func (s *SwitchClusterProtectionInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ReplicationProtectionClusterName *string `json:"replicationProtectionClusterName,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ReplicationProtectionClusterName = decoded.ReplicationProtectionClusterName + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SwitchClusterProtectionInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalSwitchClusterProtectionProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'SwitchClusterProtectionInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchclusterprotectionproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchclusterprotectionproviderspecificinput.go new file mode 100644 index 00000000000..acc419f50ba --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchclusterprotectionproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +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 SwitchClusterProtectionProviderSpecificInput interface { + SwitchClusterProtectionProviderSpecificInput() BaseSwitchClusterProtectionProviderSpecificInputImpl +} + +var _ SwitchClusterProtectionProviderSpecificInput = BaseSwitchClusterProtectionProviderSpecificInputImpl{} + +type BaseSwitchClusterProtectionProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseSwitchClusterProtectionProviderSpecificInputImpl) SwitchClusterProtectionProviderSpecificInput() BaseSwitchClusterProtectionProviderSpecificInputImpl { + return s +} + +var _ SwitchClusterProtectionProviderSpecificInput = RawSwitchClusterProtectionProviderSpecificInputImpl{} + +// RawSwitchClusterProtectionProviderSpecificInputImpl 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 RawSwitchClusterProtectionProviderSpecificInputImpl struct { + switchClusterProtectionProviderSpecificInput BaseSwitchClusterProtectionProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawSwitchClusterProtectionProviderSpecificInputImpl) SwitchClusterProtectionProviderSpecificInput() BaseSwitchClusterProtectionProviderSpecificInputImpl { + return s.switchClusterProtectionProviderSpecificInput +} + +func UnmarshalSwitchClusterProtectionProviderSpecificInputImplementation(input []byte) (SwitchClusterProtectionProviderSpecificInput, 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 SwitchClusterProtectionProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2ASwitchClusterProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ASwitchClusterProtectionInput: %+v", err) + } + return out, nil + } + + var parent BaseSwitchClusterProtectionProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSwitchClusterProtectionProviderSpecificInputImpl: %+v", err) + } + + return RawSwitchClusterProtectionProviderSpecificInputImpl{ + switchClusterProtectionProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchprotectioninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchprotectioninput.go new file mode 100644 index 00000000000..ebb469d6c10 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchprotectioninput.go @@ -0,0 +1,8 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwitchProtectionInput struct { + Properties *SwitchProtectionInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchprotectioninputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchprotectioninputproperties.go new file mode 100644 index 00000000000..1beb52fc599 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchprotectioninputproperties.go @@ -0,0 +1,42 @@ +package replicationprotectioncontainers + +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 SwitchProtectionInputProperties struct { + ProviderSpecificDetails SwitchProtectionProviderSpecificInput `json:"providerSpecificDetails"` + ReplicationProtectedItemName *string `json:"replicationProtectedItemName,omitempty"` +} + +var _ json.Unmarshaler = &SwitchProtectionInputProperties{} + +func (s *SwitchProtectionInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ReplicationProtectedItemName *string `json:"replicationProtectedItemName,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ReplicationProtectedItemName = decoded.ReplicationProtectedItemName + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SwitchProtectionInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalSwitchProtectionProviderSpecificInputImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'SwitchProtectionInputProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchprotectionproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchprotectionproviderspecificinput.go new file mode 100644 index 00000000000..1a50b26958a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_switchprotectionproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationprotectioncontainers + +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 SwitchProtectionProviderSpecificInput interface { + SwitchProtectionProviderSpecificInput() BaseSwitchProtectionProviderSpecificInputImpl +} + +var _ SwitchProtectionProviderSpecificInput = BaseSwitchProtectionProviderSpecificInputImpl{} + +type BaseSwitchProtectionProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseSwitchProtectionProviderSpecificInputImpl) SwitchProtectionProviderSpecificInput() BaseSwitchProtectionProviderSpecificInputImpl { + return s +} + +var _ SwitchProtectionProviderSpecificInput = RawSwitchProtectionProviderSpecificInputImpl{} + +// RawSwitchProtectionProviderSpecificInputImpl 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 RawSwitchProtectionProviderSpecificInputImpl struct { + switchProtectionProviderSpecificInput BaseSwitchProtectionProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawSwitchProtectionProviderSpecificInputImpl) SwitchProtectionProviderSpecificInput() BaseSwitchProtectionProviderSpecificInputImpl { + return s.switchProtectionProviderSpecificInput +} + +func UnmarshalSwitchProtectionProviderSpecificInputImplementation(input []byte) (SwitchProtectionProviderSpecificInput, 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 SwitchProtectionProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2ASwitchProtectionInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ASwitchProtectionInput: %+v", err) + } + return out, nil + } + + var parent BaseSwitchProtectionProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSwitchProtectionProviderSpecificInputImpl: %+v", err) + } + + return RawSwitchProtectionProviderSpecificInputImpl{ + switchProtectionProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_vmwarecbtcontainercreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_vmwarecbtcontainercreationinput.go new file mode 100644 index 00000000000..bea3e3c4f93 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/model_vmwarecbtcontainercreationinput.go @@ -0,0 +1,49 @@ +package replicationprotectioncontainers + +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 _ ReplicationProviderSpecificContainerCreationInput = VMwareCbtContainerCreationInput{} + +type VMwareCbtContainerCreationInput struct { + + // Fields inherited from ReplicationProviderSpecificContainerCreationInput + + InstanceType string `json:"instanceType"` +} + +func (s VMwareCbtContainerCreationInput) ReplicationProviderSpecificContainerCreationInput() BaseReplicationProviderSpecificContainerCreationInputImpl { + return BaseReplicationProviderSpecificContainerCreationInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = VMwareCbtContainerCreationInput{} + +func (s VMwareCbtContainerCreationInput) MarshalJSON() ([]byte, error) { + type wrapper VMwareCbtContainerCreationInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VMwareCbtContainerCreationInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VMwareCbtContainerCreationInput: %+v", err) + } + + decoded["instanceType"] = "VMwareCbt" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VMwareCbtContainerCreationInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/predicates.go new file mode 100644 index 00000000000..842a1e7ff08 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/predicates.go @@ -0,0 +1,32 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectionContainerOperationPredicate) Matches(input ProtectionContainer) 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/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/version.go new file mode 100644 index 00000000000..4c79c2c34a9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectioncontainers/version.go @@ -0,0 +1,10 @@ +package replicationprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationprotectioncontainers/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/README.md new file mode 100644 index 00000000000..2ec4b276a04 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/README.md @@ -0,0 +1,74 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents` Documentation + +The `replicationprotectionintents` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents" +``` + + +### Client Initialization + +```go +client := replicationprotectionintents.NewReplicationProtectionIntentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationProtectionIntentsClient.Create` + +```go +ctx := context.TODO() +id := replicationprotectionintents.NewReplicationProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationProtectionIntentName") + +payload := replicationprotectionintents.CreateProtectionIntentInput{ + // ... +} + + +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: `ReplicationProtectionIntentsClient.Get` + +```go +ctx := context.TODO() +id := replicationprotectionintents.NewReplicationProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationProtectionIntentName") + +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: `ReplicationProtectionIntentsClient.List` + +```go +ctx := context.TODO() +id := replicationprotectionintents.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id, replicationprotectionintents.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, replicationprotectionintents.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/client.go new file mode 100644 index 00000000000..188347bfd7e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/client.go @@ -0,0 +1,26 @@ +package replicationprotectionintents + +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 ReplicationProtectionIntentsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationProtectionIntentsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationProtectionIntentsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationprotectionintents", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationProtectionIntentsClient: %+v", err) + } + + return &ReplicationProtectionIntentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/constants.go new file mode 100644 index 00000000000..359018e5915 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/constants.go @@ -0,0 +1,218 @@ +package replicationprotectionintents + +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 A2ARecoveryAvailabilityType string + +const ( + A2ARecoveryAvailabilityTypeAvailabilitySet A2ARecoveryAvailabilityType = "AvailabilitySet" + A2ARecoveryAvailabilityTypeAvailabilityZone A2ARecoveryAvailabilityType = "AvailabilityZone" + A2ARecoveryAvailabilityTypeSingle A2ARecoveryAvailabilityType = "Single" +) + +func PossibleValuesForA2ARecoveryAvailabilityType() []string { + return []string{ + string(A2ARecoveryAvailabilityTypeAvailabilitySet), + string(A2ARecoveryAvailabilityTypeAvailabilityZone), + string(A2ARecoveryAvailabilityTypeSingle), + } +} + +func (s *A2ARecoveryAvailabilityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseA2ARecoveryAvailabilityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseA2ARecoveryAvailabilityType(input string) (*A2ARecoveryAvailabilityType, error) { + vals := map[string]A2ARecoveryAvailabilityType{ + "availabilityset": A2ARecoveryAvailabilityTypeAvailabilitySet, + "availabilityzone": A2ARecoveryAvailabilityTypeAvailabilityZone, + "single": A2ARecoveryAvailabilityTypeSingle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := A2ARecoveryAvailabilityType(input) + return &out, nil +} + +type AgentAutoUpdateStatus string + +const ( + AgentAutoUpdateStatusDisabled AgentAutoUpdateStatus = "Disabled" + AgentAutoUpdateStatusEnabled AgentAutoUpdateStatus = "Enabled" +) + +func PossibleValuesForAgentAutoUpdateStatus() []string { + return []string{ + string(AgentAutoUpdateStatusDisabled), + string(AgentAutoUpdateStatusEnabled), + } +} + +func (s *AgentAutoUpdateStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentAutoUpdateStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentAutoUpdateStatus(input string) (*AgentAutoUpdateStatus, error) { + vals := map[string]AgentAutoUpdateStatus{ + "disabled": AgentAutoUpdateStatusDisabled, + "enabled": AgentAutoUpdateStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentAutoUpdateStatus(input) + return &out, nil +} + +type AutoProtectionOfDataDisk string + +const ( + AutoProtectionOfDataDiskDisabled AutoProtectionOfDataDisk = "Disabled" + AutoProtectionOfDataDiskEnabled AutoProtectionOfDataDisk = "Enabled" +) + +func PossibleValuesForAutoProtectionOfDataDisk() []string { + return []string{ + string(AutoProtectionOfDataDiskDisabled), + string(AutoProtectionOfDataDiskEnabled), + } +} + +func (s *AutoProtectionOfDataDisk) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoProtectionOfDataDisk(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoProtectionOfDataDisk(input string) (*AutoProtectionOfDataDisk, error) { + vals := map[string]AutoProtectionOfDataDisk{ + "disabled": AutoProtectionOfDataDiskDisabled, + "enabled": AutoProtectionOfDataDiskEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoProtectionOfDataDisk(input) + return &out, nil +} + +type AutomationAccountAuthenticationType string + +const ( + AutomationAccountAuthenticationTypeRunAsAccount AutomationAccountAuthenticationType = "RunAsAccount" + AutomationAccountAuthenticationTypeSystemAssignedIdentity AutomationAccountAuthenticationType = "SystemAssignedIdentity" +) + +func PossibleValuesForAutomationAccountAuthenticationType() []string { + return []string{ + string(AutomationAccountAuthenticationTypeRunAsAccount), + string(AutomationAccountAuthenticationTypeSystemAssignedIdentity), + } +} + +func (s *AutomationAccountAuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutomationAccountAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutomationAccountAuthenticationType(input string) (*AutomationAccountAuthenticationType, error) { + vals := map[string]AutomationAccountAuthenticationType{ + "runasaccount": AutomationAccountAuthenticationTypeRunAsAccount, + "systemassignedidentity": AutomationAccountAuthenticationTypeSystemAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutomationAccountAuthenticationType(input) + return &out, nil +} + +type SetMultiVMSyncStatus string + +const ( + SetMultiVMSyncStatusDisable SetMultiVMSyncStatus = "Disable" + SetMultiVMSyncStatusEnable SetMultiVMSyncStatus = "Enable" +) + +func PossibleValuesForSetMultiVMSyncStatus() []string { + return []string{ + string(SetMultiVMSyncStatusDisable), + string(SetMultiVMSyncStatusEnable), + } +} + +func (s *SetMultiVMSyncStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSetMultiVMSyncStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSetMultiVMSyncStatus(input string) (*SetMultiVMSyncStatus, error) { + vals := map[string]SetMultiVMSyncStatus{ + "disable": SetMultiVMSyncStatusDisable, + "enable": SetMultiVMSyncStatusEnable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SetMultiVMSyncStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/id_replicationprotectionintent.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/id_replicationprotectionintent.go new file mode 100644 index 00000000000..78e9627f11f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/id_replicationprotectionintent.go @@ -0,0 +1,139 @@ +package replicationprotectionintents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectionIntentId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectionIntentId{} + +// ReplicationProtectionIntentId is a struct representing the Resource ID for a Replication Protection Intent +type ReplicationProtectionIntentId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationProtectionIntentName string +} + +// NewReplicationProtectionIntentID returns a new ReplicationProtectionIntentId struct +func NewReplicationProtectionIntentID(subscriptionId string, resourceGroupName string, vaultName string, replicationProtectionIntentName string) ReplicationProtectionIntentId { + return ReplicationProtectionIntentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationProtectionIntentName: replicationProtectionIntentName, + } +} + +// ParseReplicationProtectionIntentID parses 'input' into a ReplicationProtectionIntentId +func ParseReplicationProtectionIntentID(input string) (*ReplicationProtectionIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionIntentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionIntentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectionIntentIDInsensitively parses 'input' case-insensitively into a ReplicationProtectionIntentId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectionIntentIDInsensitively(input string) (*ReplicationProtectionIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectionIntentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectionIntentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectionIntentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationProtectionIntentName, ok = input.Parsed["replicationProtectionIntentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionIntentName", input) + } + + return nil +} + +// ValidateReplicationProtectionIntentID checks that 'input' can be parsed as a Replication Protection Intent ID +func ValidateReplicationProtectionIntentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectionIntentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protection Intent ID +func (id ReplicationProtectionIntentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationProtectionIntents/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationProtectionIntentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protection Intent ID +func (id ReplicationProtectionIntentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationProtectionIntents", "replicationProtectionIntents", "replicationProtectionIntents"), + resourceids.UserSpecifiedSegment("replicationProtectionIntentName", "replicationProtectionIntentName"), + } +} + +// String returns a human-readable description of this Replication Protection Intent ID +func (id ReplicationProtectionIntentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Protection Intent Name: %q", id.ReplicationProtectionIntentName), + } + return fmt.Sprintf("Replication Protection Intent (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/id_replicationprotectionintent_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/id_replicationprotectionintent_test.go new file mode 100644 index 00000000000..b3dedc733d4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/id_replicationprotectionintent_test.go @@ -0,0 +1,327 @@ +package replicationprotectionintents + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectionIntentId{} + +func TestNewReplicationProtectionIntentID(t *testing.T) { + id := NewReplicationProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationProtectionIntentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationProtectionIntentName != "replicationProtectionIntentName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionIntentName'", id.ReplicationProtectionIntentName, "replicationProtectionIntentName") + } +} + +func TestFormatReplicationProtectionIntentID(t *testing.T) { + actual := NewReplicationProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationProtectionIntentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationProtectionIntents/replicationProtectionIntentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectionIntentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionIntentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationProtectionIntents", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationProtectionIntents/replicationProtectionIntentName", + Expected: &ReplicationProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationProtectionIntentName: "replicationProtectionIntentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationProtectionIntents/replicationProtectionIntentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionIntentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationProtectionIntentName != v.Expected.ReplicationProtectionIntentName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionIntentName", v.Expected.ReplicationProtectionIntentName, actual.ReplicationProtectionIntentName) + } + + } +} + +func TestParseReplicationProtectionIntentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectionIntentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationProtectionIntents", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnPrOtEcTiOnInTeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationProtectionIntents/replicationProtectionIntentName", + Expected: &ReplicationProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationProtectionIntentName: "replicationProtectionIntentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationProtectionIntents/replicationProtectionIntentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnPrOtEcTiOnInTeNtS/rEpLiCaTiOnPrOtEcTiOnInTeNtNaMe", + Expected: &ReplicationProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationProtectionIntentName: "rEpLiCaTiOnPrOtEcTiOnInTeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnPrOtEcTiOnInTeNtS/rEpLiCaTiOnPrOtEcTiOnInTeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectionIntentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationProtectionIntentName != v.Expected.ReplicationProtectionIntentName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionIntentName", v.Expected.ReplicationProtectionIntentName, actual.ReplicationProtectionIntentName) + } + + } +} + +func TestSegmentsForReplicationProtectionIntentId(t *testing.T) { + segments := ReplicationProtectionIntentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectionIntentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/id_vault.go new file mode 100644 index 00000000000..4df44daf2b0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/id_vault.go @@ -0,0 +1,130 @@ +package replicationprotectionintents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/id_vault_test.go new file mode 100644 index 00000000000..deb409a106d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationprotectionintents + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/method_create.go new file mode 100644 index 00000000000..82af2c6bbb0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/method_create.go @@ -0,0 +1,57 @@ +package replicationprotectionintents + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ReplicationProtectionIntent +} + +// Create ... +func (c ReplicationProtectionIntentsClient) Create(ctx context.Context, id ReplicationProtectionIntentId, input CreateProtectionIntentInput) (result CreateOperationResponse, 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 ReplicationProtectionIntent + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/method_get.go new file mode 100644 index 00000000000..0352aeb3e5c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/method_get.go @@ -0,0 +1,53 @@ +package replicationprotectionintents + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ReplicationProtectionIntent +} + +// Get ... +func (c ReplicationProtectionIntentsClient) Get(ctx context.Context, id ReplicationProtectionIntentId) (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 ReplicationProtectionIntent + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/method_list.go new file mode 100644 index 00000000000..6948c72b429 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/method_list.go @@ -0,0 +1,138 @@ +package replicationprotectionintents + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ReplicationProtectionIntent +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReplicationProtectionIntent +} + +type ListOperationOptions struct { + SkipToken *string + TakeToken *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.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.TakeToken != nil { + out.Append("takeToken", fmt.Sprintf("%v", *o.TakeToken)) + } + 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 ReplicationProtectionIntentsClient) List(ctx context.Context, id VaultId, 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/replicationProtectionIntents", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReplicationProtectionIntent `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 ReplicationProtectionIntentsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ReplicationProtectionIntentOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationProtectionIntentsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ReplicationProtectionIntentOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ReplicationProtectionIntent, 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/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_a2acreateprotectionintentinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_a2acreateprotectionintentinput.go new file mode 100644 index 00000000000..36cf09c2d97 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_a2acreateprotectionintentinput.go @@ -0,0 +1,171 @@ +package replicationprotectionintents + +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 _ CreateProtectionIntentProviderSpecificDetails = A2ACreateProtectionIntentInput{} + +type A2ACreateProtectionIntentInput struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + FabricObjectId string `json:"fabricObjectId"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + PrimaryLocation string `json:"primaryLocation"` + PrimaryStagingStorageAccountCustomInput StorageAccountCustomDetails `json:"primaryStagingStorageAccountCustomInput"` + ProtectionProfileCustomInput ProtectionProfileCustomDetails `json:"protectionProfileCustomInput"` + RecoveryAvailabilitySetCustomInput RecoveryAvailabilitySetCustomDetails `json:"recoveryAvailabilitySetCustomInput"` + RecoveryAvailabilityType A2ARecoveryAvailabilityType `json:"recoveryAvailabilityType"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryBootDiagStorageAccount StorageAccountCustomDetails `json:"recoveryBootDiagStorageAccount"` + RecoveryLocation string `json:"recoveryLocation"` + RecoveryProximityPlacementGroupCustomInput RecoveryProximityPlacementGroupCustomDetails `json:"recoveryProximityPlacementGroupCustomInput"` + RecoveryResourceGroupId string `json:"recoveryResourceGroupId"` + RecoverySubscriptionId string `json:"recoverySubscriptionId"` + RecoveryVirtualNetworkCustomInput RecoveryVirtualNetworkCustomDetails `json:"recoveryVirtualNetworkCustomInput"` + VMDisks *[]A2AProtectionIntentDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AProtectionIntentManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from CreateProtectionIntentProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s A2ACreateProtectionIntentInput) CreateProtectionIntentProviderSpecificDetails() BaseCreateProtectionIntentProviderSpecificDetailsImpl { + return BaseCreateProtectionIntentProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2ACreateProtectionIntentInput{} + +func (s A2ACreateProtectionIntentInput) MarshalJSON() ([]byte, error) { + type wrapper A2ACreateProtectionIntentInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2ACreateProtectionIntentInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2ACreateProtectionIntentInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2ACreateProtectionIntentInput: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &A2ACreateProtectionIntentInput{} + +func (s *A2ACreateProtectionIntentInput) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + FabricObjectId string `json:"fabricObjectId"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + PrimaryLocation string `json:"primaryLocation"` + RecoveryAvailabilityType A2ARecoveryAvailabilityType `json:"recoveryAvailabilityType"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryLocation string `json:"recoveryLocation"` + RecoveryResourceGroupId string `json:"recoveryResourceGroupId"` + RecoverySubscriptionId string `json:"recoverySubscriptionId"` + VMDisks *[]A2AProtectionIntentDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AProtectionIntentManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + InstanceType string `json:"instanceType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AgentAutoUpdateStatus = decoded.AgentAutoUpdateStatus + s.AutoProtectionOfDataDisk = decoded.AutoProtectionOfDataDisk + s.AutomationAccountArmId = decoded.AutomationAccountArmId + s.AutomationAccountAuthenticationType = decoded.AutomationAccountAuthenticationType + s.DiskEncryptionInfo = decoded.DiskEncryptionInfo + s.FabricObjectId = decoded.FabricObjectId + s.MultiVMGroupId = decoded.MultiVMGroupId + s.MultiVMGroupName = decoded.MultiVMGroupName + s.PrimaryLocation = decoded.PrimaryLocation + s.RecoveryAvailabilityType = decoded.RecoveryAvailabilityType + s.RecoveryAvailabilityZone = decoded.RecoveryAvailabilityZone + s.RecoveryLocation = decoded.RecoveryLocation + s.RecoveryResourceGroupId = decoded.RecoveryResourceGroupId + s.RecoverySubscriptionId = decoded.RecoverySubscriptionId + s.VMDisks = decoded.VMDisks + s.VMManagedDisks = decoded.VMManagedDisks + s.InstanceType = decoded.InstanceType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling A2ACreateProtectionIntentInput into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["primaryStagingStorageAccountCustomInput"]; ok { + impl, err := UnmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PrimaryStagingStorageAccountCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.PrimaryStagingStorageAccountCustomInput = impl + } + + if v, ok := temp["protectionProfileCustomInput"]; ok { + impl, err := UnmarshalProtectionProfileCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProtectionProfileCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.ProtectionProfileCustomInput = impl + } + + if v, ok := temp["recoveryAvailabilitySetCustomInput"]; ok { + impl, err := UnmarshalRecoveryAvailabilitySetCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryAvailabilitySetCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.RecoveryAvailabilitySetCustomInput = impl + } + + if v, ok := temp["recoveryBootDiagStorageAccount"]; ok { + impl, err := UnmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryBootDiagStorageAccount' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.RecoveryBootDiagStorageAccount = impl + } + + if v, ok := temp["recoveryProximityPlacementGroupCustomInput"]; ok { + impl, err := UnmarshalRecoveryProximityPlacementGroupCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryProximityPlacementGroupCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.RecoveryProximityPlacementGroupCustomInput = impl + } + + if v, ok := temp["recoveryVirtualNetworkCustomInput"]; ok { + impl, err := UnmarshalRecoveryVirtualNetworkCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryVirtualNetworkCustomInput' for 'A2ACreateProtectionIntentInput': %+v", err) + } + s.RecoveryVirtualNetworkCustomInput = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_a2aprotectionintentdiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_a2aprotectionintentdiskinputdetails.go new file mode 100644 index 00000000000..6d8ccd708cd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_a2aprotectionintentdiskinputdetails.go @@ -0,0 +1,51 @@ +package replicationprotectionintents + +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 A2AProtectionIntentDiskInputDetails struct { + DiskUri string `json:"diskUri"` + PrimaryStagingStorageAccountCustomInput StorageAccountCustomDetails `json:"primaryStagingStorageAccountCustomInput"` + RecoveryAzureStorageAccountCustomInput StorageAccountCustomDetails `json:"recoveryAzureStorageAccountCustomInput"` +} + +var _ json.Unmarshaler = &A2AProtectionIntentDiskInputDetails{} + +func (s *A2AProtectionIntentDiskInputDetails) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DiskUri string `json:"diskUri"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DiskUri = decoded.DiskUri + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling A2AProtectionIntentDiskInputDetails into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["primaryStagingStorageAccountCustomInput"]; ok { + impl, err := UnmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PrimaryStagingStorageAccountCustomInput' for 'A2AProtectionIntentDiskInputDetails': %+v", err) + } + s.PrimaryStagingStorageAccountCustomInput = impl + } + + if v, ok := temp["recoveryAzureStorageAccountCustomInput"]; ok { + impl, err := UnmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryAzureStorageAccountCustomInput' for 'A2AProtectionIntentDiskInputDetails': %+v", err) + } + s.RecoveryAzureStorageAccountCustomInput = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_a2aprotectionintentmanageddiskinputdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_a2aprotectionintentmanageddiskinputdetails.go new file mode 100644 index 00000000000..29dcc90679e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_a2aprotectionintentmanageddiskinputdetails.go @@ -0,0 +1,63 @@ +package replicationprotectionintents + +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 A2AProtectionIntentManagedDiskInputDetails struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + DiskId string `json:"diskId"` + PrimaryStagingStorageAccountCustomInput StorageAccountCustomDetails `json:"primaryStagingStorageAccountCustomInput"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryResourceGroupCustomInput RecoveryResourceGroupCustomDetails `json:"recoveryResourceGroupCustomInput"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` +} + +var _ json.Unmarshaler = &A2AProtectionIntentManagedDiskInputDetails{} + +func (s *A2AProtectionIntentManagedDiskInputDetails) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + DiskId string `json:"diskId"` + RecoveryDiskEncryptionSetId *string `json:"recoveryDiskEncryptionSetId,omitempty"` + RecoveryReplicaDiskAccountType *string `json:"recoveryReplicaDiskAccountType,omitempty"` + RecoveryTargetDiskAccountType *string `json:"recoveryTargetDiskAccountType,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DiskEncryptionInfo = decoded.DiskEncryptionInfo + s.DiskId = decoded.DiskId + s.RecoveryDiskEncryptionSetId = decoded.RecoveryDiskEncryptionSetId + s.RecoveryReplicaDiskAccountType = decoded.RecoveryReplicaDiskAccountType + s.RecoveryTargetDiskAccountType = decoded.RecoveryTargetDiskAccountType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling A2AProtectionIntentManagedDiskInputDetails into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["primaryStagingStorageAccountCustomInput"]; ok { + impl, err := UnmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PrimaryStagingStorageAccountCustomInput' for 'A2AProtectionIntentManagedDiskInputDetails': %+v", err) + } + s.PrimaryStagingStorageAccountCustomInput = impl + } + + if v, ok := temp["recoveryResourceGroupCustomInput"]; ok { + impl, err := UnmarshalRecoveryResourceGroupCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryResourceGroupCustomInput' for 'A2AProtectionIntentManagedDiskInputDetails': %+v", err) + } + s.RecoveryResourceGroupCustomInput = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_a2areplicationintentdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_a2areplicationintentdetails.go new file mode 100644 index 00000000000..1285ba3a5c4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_a2areplicationintentdetails.go @@ -0,0 +1,171 @@ +package replicationprotectionintents + +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 _ ReplicationProtectionIntentProviderSpecificSettings = A2AReplicationIntentDetails{} + +type A2AReplicationIntentDetails struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + PrimaryLocation *string `json:"primaryLocation,omitempty"` + PrimaryStagingStorageAccount StorageAccountCustomDetails `json:"primaryStagingStorageAccount"` + ProtectionProfile ProtectionProfileCustomDetails `json:"protectionProfile"` + RecoveryAvailabilitySet RecoveryAvailabilitySetCustomDetails `json:"recoveryAvailabilitySet"` + RecoveryAvailabilityType string `json:"recoveryAvailabilityType"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryBootDiagStorageAccount StorageAccountCustomDetails `json:"recoveryBootDiagStorageAccount"` + RecoveryLocation *string `json:"recoveryLocation,omitempty"` + RecoveryProximityPlacementGroup RecoveryProximityPlacementGroupCustomDetails `json:"recoveryProximityPlacementGroup"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoverySubscriptionId *string `json:"recoverySubscriptionId,omitempty"` + RecoveryVirtualNetwork RecoveryVirtualNetworkCustomDetails `json:"recoveryVirtualNetwork"` + VMDisks *[]A2AProtectionIntentDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AProtectionIntentManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + + // Fields inherited from ReplicationProtectionIntentProviderSpecificSettings + + InstanceType string `json:"instanceType"` +} + +func (s A2AReplicationIntentDetails) ReplicationProtectionIntentProviderSpecificSettings() BaseReplicationProtectionIntentProviderSpecificSettingsImpl { + return BaseReplicationProtectionIntentProviderSpecificSettingsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = A2AReplicationIntentDetails{} + +func (s A2AReplicationIntentDetails) MarshalJSON() ([]byte, error) { + type wrapper A2AReplicationIntentDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling A2AReplicationIntentDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling A2AReplicationIntentDetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling A2AReplicationIntentDetails: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &A2AReplicationIntentDetails{} + +func (s *A2AReplicationIntentDetails) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AgentAutoUpdateStatus *AgentAutoUpdateStatus `json:"agentAutoUpdateStatus,omitempty"` + AutoProtectionOfDataDisk *AutoProtectionOfDataDisk `json:"autoProtectionOfDataDisk,omitempty"` + AutomationAccountArmId *string `json:"automationAccountArmId,omitempty"` + AutomationAccountAuthenticationType *AutomationAccountAuthenticationType `json:"automationAccountAuthenticationType,omitempty"` + DiskEncryptionInfo *DiskEncryptionInfo `json:"diskEncryptionInfo,omitempty"` + FabricObjectId *string `json:"fabricObjectId,omitempty"` + MultiVMGroupId *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + PrimaryLocation *string `json:"primaryLocation,omitempty"` + RecoveryAvailabilityType string `json:"recoveryAvailabilityType"` + RecoveryAvailabilityZone *string `json:"recoveryAvailabilityZone,omitempty"` + RecoveryLocation *string `json:"recoveryLocation,omitempty"` + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + RecoverySubscriptionId *string `json:"recoverySubscriptionId,omitempty"` + VMDisks *[]A2AProtectionIntentDiskInputDetails `json:"vmDisks,omitempty"` + VMManagedDisks *[]A2AProtectionIntentManagedDiskInputDetails `json:"vmManagedDisks,omitempty"` + InstanceType string `json:"instanceType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AgentAutoUpdateStatus = decoded.AgentAutoUpdateStatus + s.AutoProtectionOfDataDisk = decoded.AutoProtectionOfDataDisk + s.AutomationAccountArmId = decoded.AutomationAccountArmId + s.AutomationAccountAuthenticationType = decoded.AutomationAccountAuthenticationType + s.DiskEncryptionInfo = decoded.DiskEncryptionInfo + s.FabricObjectId = decoded.FabricObjectId + s.MultiVMGroupId = decoded.MultiVMGroupId + s.MultiVMGroupName = decoded.MultiVMGroupName + s.PrimaryLocation = decoded.PrimaryLocation + s.RecoveryAvailabilityType = decoded.RecoveryAvailabilityType + s.RecoveryAvailabilityZone = decoded.RecoveryAvailabilityZone + s.RecoveryLocation = decoded.RecoveryLocation + s.RecoveryResourceGroupId = decoded.RecoveryResourceGroupId + s.RecoverySubscriptionId = decoded.RecoverySubscriptionId + s.VMDisks = decoded.VMDisks + s.VMManagedDisks = decoded.VMManagedDisks + s.InstanceType = decoded.InstanceType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling A2AReplicationIntentDetails into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["primaryStagingStorageAccount"]; ok { + impl, err := UnmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PrimaryStagingStorageAccount' for 'A2AReplicationIntentDetails': %+v", err) + } + s.PrimaryStagingStorageAccount = impl + } + + if v, ok := temp["protectionProfile"]; ok { + impl, err := UnmarshalProtectionProfileCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProtectionProfile' for 'A2AReplicationIntentDetails': %+v", err) + } + s.ProtectionProfile = impl + } + + if v, ok := temp["recoveryAvailabilitySet"]; ok { + impl, err := UnmarshalRecoveryAvailabilitySetCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryAvailabilitySet' for 'A2AReplicationIntentDetails': %+v", err) + } + s.RecoveryAvailabilitySet = impl + } + + if v, ok := temp["recoveryBootDiagStorageAccount"]; ok { + impl, err := UnmarshalStorageAccountCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryBootDiagStorageAccount' for 'A2AReplicationIntentDetails': %+v", err) + } + s.RecoveryBootDiagStorageAccount = impl + } + + if v, ok := temp["recoveryProximityPlacementGroup"]; ok { + impl, err := UnmarshalRecoveryProximityPlacementGroupCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryProximityPlacementGroup' for 'A2AReplicationIntentDetails': %+v", err) + } + s.RecoveryProximityPlacementGroup = impl + } + + if v, ok := temp["recoveryVirtualNetwork"]; ok { + impl, err := UnmarshalRecoveryVirtualNetworkCustomDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RecoveryVirtualNetwork' for 'A2AReplicationIntentDetails': %+v", err) + } + s.RecoveryVirtualNetwork = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_createprotectionintentinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_createprotectionintentinput.go new file mode 100644 index 00000000000..043880b900a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_createprotectionintentinput.go @@ -0,0 +1,8 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateProtectionIntentInput struct { + Properties *CreateProtectionIntentProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_createprotectionintentproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_createprotectionintentproperties.go new file mode 100644 index 00000000000..cf70e55deb4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_createprotectionintentproperties.go @@ -0,0 +1,33 @@ +package replicationprotectionintents + +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 CreateProtectionIntentProperties struct { + ProviderSpecificDetails CreateProtectionIntentProviderSpecificDetails `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &CreateProtectionIntentProperties{} + +func (s *CreateProtectionIntentProperties) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateProtectionIntentProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalCreateProtectionIntentProviderSpecificDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'CreateProtectionIntentProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_createprotectionintentproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_createprotectionintentproviderspecificdetails.go new file mode 100644 index 00000000000..ab7fd077002 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_createprotectionintentproviderspecificdetails.go @@ -0,0 +1,75 @@ +package replicationprotectionintents + +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 CreateProtectionIntentProviderSpecificDetails interface { + CreateProtectionIntentProviderSpecificDetails() BaseCreateProtectionIntentProviderSpecificDetailsImpl +} + +var _ CreateProtectionIntentProviderSpecificDetails = BaseCreateProtectionIntentProviderSpecificDetailsImpl{} + +type BaseCreateProtectionIntentProviderSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseCreateProtectionIntentProviderSpecificDetailsImpl) CreateProtectionIntentProviderSpecificDetails() BaseCreateProtectionIntentProviderSpecificDetailsImpl { + return s +} + +var _ CreateProtectionIntentProviderSpecificDetails = RawCreateProtectionIntentProviderSpecificDetailsImpl{} + +// RawCreateProtectionIntentProviderSpecificDetailsImpl 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 RawCreateProtectionIntentProviderSpecificDetailsImpl struct { + createProtectionIntentProviderSpecificDetails BaseCreateProtectionIntentProviderSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawCreateProtectionIntentProviderSpecificDetailsImpl) CreateProtectionIntentProviderSpecificDetails() BaseCreateProtectionIntentProviderSpecificDetailsImpl { + return s.createProtectionIntentProviderSpecificDetails +} + +func UnmarshalCreateProtectionIntentProviderSpecificDetailsImplementation(input []byte) (CreateProtectionIntentProviderSpecificDetails, 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 CreateProtectionIntentProviderSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2ACreateProtectionIntentInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2ACreateProtectionIntentInput: %+v", err) + } + return out, nil + } + + var parent BaseCreateProtectionIntentProviderSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseCreateProtectionIntentProviderSpecificDetailsImpl: %+v", err) + } + + return RawCreateProtectionIntentProviderSpecificDetailsImpl{ + createProtectionIntentProviderSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_diskencryptioninfo.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_diskencryptioninfo.go new file mode 100644 index 00000000000..bbe499d7f6b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_diskencryptioninfo.go @@ -0,0 +1,9 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionInfo struct { + DiskEncryptionKeyInfo *DiskEncryptionKeyInfo `json:"diskEncryptionKeyInfo,omitempty"` + KeyEncryptionKeyInfo *KeyEncryptionKeyInfo `json:"keyEncryptionKeyInfo,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_diskencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_diskencryptionkeyinfo.go new file mode 100644 index 00000000000..1043673141e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_diskencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskEncryptionKeyInfo struct { + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` + SecretIdentifier *string `json:"secretIdentifier,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingprotectionprofile.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingprotectionprofile.go new file mode 100644 index 00000000000..0b216ef5a81 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingprotectionprofile.go @@ -0,0 +1,50 @@ +package replicationprotectionintents + +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 _ ProtectionProfileCustomDetails = ExistingProtectionProfile{} + +type ExistingProtectionProfile struct { + ProtectionProfileId string `json:"protectionProfileId"` + + // Fields inherited from ProtectionProfileCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s ExistingProtectionProfile) ProtectionProfileCustomDetails() BaseProtectionProfileCustomDetailsImpl { + return BaseProtectionProfileCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = ExistingProtectionProfile{} + +func (s ExistingProtectionProfile) MarshalJSON() ([]byte, error) { + type wrapper ExistingProtectionProfile + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingProtectionProfile: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingProtectionProfile: %+v", err) + } + + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingProtectionProfile: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingrecoveryavailabilityset.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingrecoveryavailabilityset.go new file mode 100644 index 00000000000..843ef1f8cb7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingrecoveryavailabilityset.go @@ -0,0 +1,50 @@ +package replicationprotectionintents + +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 _ RecoveryAvailabilitySetCustomDetails = ExistingRecoveryAvailabilitySet{} + +type ExistingRecoveryAvailabilitySet struct { + RecoveryAvailabilitySetId *string `json:"recoveryAvailabilitySetId,omitempty"` + + // Fields inherited from RecoveryAvailabilitySetCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s ExistingRecoveryAvailabilitySet) RecoveryAvailabilitySetCustomDetails() BaseRecoveryAvailabilitySetCustomDetailsImpl { + return BaseRecoveryAvailabilitySetCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = ExistingRecoveryAvailabilitySet{} + +func (s ExistingRecoveryAvailabilitySet) MarshalJSON() ([]byte, error) { + type wrapper ExistingRecoveryAvailabilitySet + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingRecoveryAvailabilitySet: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingRecoveryAvailabilitySet: %+v", err) + } + + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingRecoveryAvailabilitySet: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingrecoveryproximityplacementgroup.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingrecoveryproximityplacementgroup.go new file mode 100644 index 00000000000..9ce68dbc0c1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingrecoveryproximityplacementgroup.go @@ -0,0 +1,50 @@ +package replicationprotectionintents + +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 _ RecoveryProximityPlacementGroupCustomDetails = ExistingRecoveryProximityPlacementGroup{} + +type ExistingRecoveryProximityPlacementGroup struct { + RecoveryProximityPlacementGroupId *string `json:"recoveryProximityPlacementGroupId,omitempty"` + + // Fields inherited from RecoveryProximityPlacementGroupCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s ExistingRecoveryProximityPlacementGroup) RecoveryProximityPlacementGroupCustomDetails() BaseRecoveryProximityPlacementGroupCustomDetailsImpl { + return BaseRecoveryProximityPlacementGroupCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = ExistingRecoveryProximityPlacementGroup{} + +func (s ExistingRecoveryProximityPlacementGroup) MarshalJSON() ([]byte, error) { + type wrapper ExistingRecoveryProximityPlacementGroup + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingRecoveryProximityPlacementGroup: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingRecoveryProximityPlacementGroup: %+v", err) + } + + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingRecoveryProximityPlacementGroup: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingrecoveryrecoveryresourcegroup.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingrecoveryrecoveryresourcegroup.go new file mode 100644 index 00000000000..aaeb02cfaf5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingrecoveryrecoveryresourcegroup.go @@ -0,0 +1,50 @@ +package replicationprotectionintents + +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 _ RecoveryResourceGroupCustomDetails = ExistingRecoveryRecoveryResourceGroup{} + +type ExistingRecoveryRecoveryResourceGroup struct { + RecoveryResourceGroupId *string `json:"recoveryResourceGroupId,omitempty"` + + // Fields inherited from RecoveryResourceGroupCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s ExistingRecoveryRecoveryResourceGroup) RecoveryResourceGroupCustomDetails() BaseRecoveryResourceGroupCustomDetailsImpl { + return BaseRecoveryResourceGroupCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = ExistingRecoveryRecoveryResourceGroup{} + +func (s ExistingRecoveryRecoveryResourceGroup) MarshalJSON() ([]byte, error) { + type wrapper ExistingRecoveryRecoveryResourceGroup + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingRecoveryRecoveryResourceGroup: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingRecoveryRecoveryResourceGroup: %+v", err) + } + + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingRecoveryRecoveryResourceGroup: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingrecoveryvirtualnetwork.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingrecoveryvirtualnetwork.go new file mode 100644 index 00000000000..d423cd45704 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingrecoveryvirtualnetwork.go @@ -0,0 +1,51 @@ +package replicationprotectionintents + +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 _ RecoveryVirtualNetworkCustomDetails = ExistingRecoveryVirtualNetwork{} + +type ExistingRecoveryVirtualNetwork struct { + RecoverySubnetName *string `json:"recoverySubnetName,omitempty"` + RecoveryVirtualNetworkId string `json:"recoveryVirtualNetworkId"` + + // Fields inherited from RecoveryVirtualNetworkCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s ExistingRecoveryVirtualNetwork) RecoveryVirtualNetworkCustomDetails() BaseRecoveryVirtualNetworkCustomDetailsImpl { + return BaseRecoveryVirtualNetworkCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = ExistingRecoveryVirtualNetwork{} + +func (s ExistingRecoveryVirtualNetwork) MarshalJSON() ([]byte, error) { + type wrapper ExistingRecoveryVirtualNetwork + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingRecoveryVirtualNetwork: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingRecoveryVirtualNetwork: %+v", err) + } + + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingRecoveryVirtualNetwork: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingstorageaccount.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingstorageaccount.go new file mode 100644 index 00000000000..aff65dcc0b5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_existingstorageaccount.go @@ -0,0 +1,50 @@ +package replicationprotectionintents + +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 _ StorageAccountCustomDetails = ExistingStorageAccount{} + +type ExistingStorageAccount struct { + AzureStorageAccountId string `json:"azureStorageAccountId"` + + // Fields inherited from StorageAccountCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s ExistingStorageAccount) StorageAccountCustomDetails() BaseStorageAccountCustomDetailsImpl { + return BaseStorageAccountCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = ExistingStorageAccount{} + +func (s ExistingStorageAccount) MarshalJSON() ([]byte, error) { + type wrapper ExistingStorageAccount + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ExistingStorageAccount: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ExistingStorageAccount: %+v", err) + } + + decoded["resourceType"] = "Existing" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ExistingStorageAccount: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_keyencryptionkeyinfo.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_keyencryptionkeyinfo.go new file mode 100644 index 00000000000..b4a8b6e0c54 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_keyencryptionkeyinfo.go @@ -0,0 +1,9 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyEncryptionKeyInfo struct { + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + KeyVaultResourceArmId *string `json:"keyVaultResourceArmId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_newprotectionprofile.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_newprotectionprofile.go new file mode 100644 index 00000000000..024c9f7c66e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_newprotectionprofile.go @@ -0,0 +1,54 @@ +package replicationprotectionintents + +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 _ ProtectionProfileCustomDetails = NewProtectionProfile{} + +type NewProtectionProfile struct { + AppConsistentFrequencyInMinutes *int64 `json:"appConsistentFrequencyInMinutes,omitempty"` + CrashConsistentFrequencyInMinutes *int64 `json:"crashConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus"` + PolicyName string `json:"policyName"` + RecoveryPointHistory *int64 `json:"recoveryPointHistory,omitempty"` + + // Fields inherited from ProtectionProfileCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s NewProtectionProfile) ProtectionProfileCustomDetails() BaseProtectionProfileCustomDetailsImpl { + return BaseProtectionProfileCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = NewProtectionProfile{} + +func (s NewProtectionProfile) MarshalJSON() ([]byte, error) { + type wrapper NewProtectionProfile + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NewProtectionProfile: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NewProtectionProfile: %+v", err) + } + + decoded["resourceType"] = "New" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NewProtectionProfile: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_newrecoveryvirtualnetwork.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_newrecoveryvirtualnetwork.go new file mode 100644 index 00000000000..4b1609e51d9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_newrecoveryvirtualnetwork.go @@ -0,0 +1,51 @@ +package replicationprotectionintents + +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 _ RecoveryVirtualNetworkCustomDetails = NewRecoveryVirtualNetwork{} + +type NewRecoveryVirtualNetwork struct { + RecoveryVirtualNetworkName *string `json:"recoveryVirtualNetworkName,omitempty"` + RecoveryVirtualNetworkResourceGroupName *string `json:"recoveryVirtualNetworkResourceGroupName,omitempty"` + + // Fields inherited from RecoveryVirtualNetworkCustomDetails + + ResourceType string `json:"resourceType"` +} + +func (s NewRecoveryVirtualNetwork) RecoveryVirtualNetworkCustomDetails() BaseRecoveryVirtualNetworkCustomDetailsImpl { + return BaseRecoveryVirtualNetworkCustomDetailsImpl{ + ResourceType: s.ResourceType, + } +} + +var _ json.Marshaler = NewRecoveryVirtualNetwork{} + +func (s NewRecoveryVirtualNetwork) MarshalJSON() ([]byte, error) { + type wrapper NewRecoveryVirtualNetwork + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NewRecoveryVirtualNetwork: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NewRecoveryVirtualNetwork: %+v", err) + } + + decoded["resourceType"] = "New" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NewRecoveryVirtualNetwork: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_protectionprofilecustomdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_protectionprofilecustomdetails.go new file mode 100644 index 00000000000..cfd62e1171e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_protectionprofilecustomdetails.go @@ -0,0 +1,83 @@ +package replicationprotectionintents + +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 ProtectionProfileCustomDetails interface { + ProtectionProfileCustomDetails() BaseProtectionProfileCustomDetailsImpl +} + +var _ ProtectionProfileCustomDetails = BaseProtectionProfileCustomDetailsImpl{} + +type BaseProtectionProfileCustomDetailsImpl struct { + ResourceType string `json:"resourceType"` +} + +func (s BaseProtectionProfileCustomDetailsImpl) ProtectionProfileCustomDetails() BaseProtectionProfileCustomDetailsImpl { + return s +} + +var _ ProtectionProfileCustomDetails = RawProtectionProfileCustomDetailsImpl{} + +// RawProtectionProfileCustomDetailsImpl 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 RawProtectionProfileCustomDetailsImpl struct { + protectionProfileCustomDetails BaseProtectionProfileCustomDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawProtectionProfileCustomDetailsImpl) ProtectionProfileCustomDetails() BaseProtectionProfileCustomDetailsImpl { + return s.protectionProfileCustomDetails +} + +func UnmarshalProtectionProfileCustomDetailsImplementation(input []byte) (ProtectionProfileCustomDetails, 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 ProtectionProfileCustomDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["resourceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Existing") { + var out ExistingProtectionProfile + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingProtectionProfile: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "New") { + var out NewProtectionProfile + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NewProtectionProfile: %+v", err) + } + return out, nil + } + + var parent BaseProtectionProfileCustomDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseProtectionProfileCustomDetailsImpl: %+v", err) + } + + return RawProtectionProfileCustomDetailsImpl{ + protectionProfileCustomDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_recoveryavailabilitysetcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_recoveryavailabilitysetcustomdetails.go new file mode 100644 index 00000000000..a5be859681d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_recoveryavailabilitysetcustomdetails.go @@ -0,0 +1,75 @@ +package replicationprotectionintents + +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 RecoveryAvailabilitySetCustomDetails interface { + RecoveryAvailabilitySetCustomDetails() BaseRecoveryAvailabilitySetCustomDetailsImpl +} + +var _ RecoveryAvailabilitySetCustomDetails = BaseRecoveryAvailabilitySetCustomDetailsImpl{} + +type BaseRecoveryAvailabilitySetCustomDetailsImpl struct { + ResourceType string `json:"resourceType"` +} + +func (s BaseRecoveryAvailabilitySetCustomDetailsImpl) RecoveryAvailabilitySetCustomDetails() BaseRecoveryAvailabilitySetCustomDetailsImpl { + return s +} + +var _ RecoveryAvailabilitySetCustomDetails = RawRecoveryAvailabilitySetCustomDetailsImpl{} + +// RawRecoveryAvailabilitySetCustomDetailsImpl 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 RawRecoveryAvailabilitySetCustomDetailsImpl struct { + recoveryAvailabilitySetCustomDetails BaseRecoveryAvailabilitySetCustomDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryAvailabilitySetCustomDetailsImpl) RecoveryAvailabilitySetCustomDetails() BaseRecoveryAvailabilitySetCustomDetailsImpl { + return s.recoveryAvailabilitySetCustomDetails +} + +func UnmarshalRecoveryAvailabilitySetCustomDetailsImplementation(input []byte) (RecoveryAvailabilitySetCustomDetails, 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 RecoveryAvailabilitySetCustomDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["resourceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Existing") { + var out ExistingRecoveryAvailabilitySet + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingRecoveryAvailabilitySet: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryAvailabilitySetCustomDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryAvailabilitySetCustomDetailsImpl: %+v", err) + } + + return RawRecoveryAvailabilitySetCustomDetailsImpl{ + recoveryAvailabilitySetCustomDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_recoveryproximityplacementgroupcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_recoveryproximityplacementgroupcustomdetails.go new file mode 100644 index 00000000000..cd88e1a7a13 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_recoveryproximityplacementgroupcustomdetails.go @@ -0,0 +1,75 @@ +package replicationprotectionintents + +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 RecoveryProximityPlacementGroupCustomDetails interface { + RecoveryProximityPlacementGroupCustomDetails() BaseRecoveryProximityPlacementGroupCustomDetailsImpl +} + +var _ RecoveryProximityPlacementGroupCustomDetails = BaseRecoveryProximityPlacementGroupCustomDetailsImpl{} + +type BaseRecoveryProximityPlacementGroupCustomDetailsImpl struct { + ResourceType string `json:"resourceType"` +} + +func (s BaseRecoveryProximityPlacementGroupCustomDetailsImpl) RecoveryProximityPlacementGroupCustomDetails() BaseRecoveryProximityPlacementGroupCustomDetailsImpl { + return s +} + +var _ RecoveryProximityPlacementGroupCustomDetails = RawRecoveryProximityPlacementGroupCustomDetailsImpl{} + +// RawRecoveryProximityPlacementGroupCustomDetailsImpl 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 RawRecoveryProximityPlacementGroupCustomDetailsImpl struct { + recoveryProximityPlacementGroupCustomDetails BaseRecoveryProximityPlacementGroupCustomDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryProximityPlacementGroupCustomDetailsImpl) RecoveryProximityPlacementGroupCustomDetails() BaseRecoveryProximityPlacementGroupCustomDetailsImpl { + return s.recoveryProximityPlacementGroupCustomDetails +} + +func UnmarshalRecoveryProximityPlacementGroupCustomDetailsImplementation(input []byte) (RecoveryProximityPlacementGroupCustomDetails, 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 RecoveryProximityPlacementGroupCustomDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["resourceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Existing") { + var out ExistingRecoveryProximityPlacementGroup + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingRecoveryProximityPlacementGroup: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryProximityPlacementGroupCustomDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryProximityPlacementGroupCustomDetailsImpl: %+v", err) + } + + return RawRecoveryProximityPlacementGroupCustomDetailsImpl{ + recoveryProximityPlacementGroupCustomDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_recoveryresourcegroupcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_recoveryresourcegroupcustomdetails.go new file mode 100644 index 00000000000..784f54bebcf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_recoveryresourcegroupcustomdetails.go @@ -0,0 +1,75 @@ +package replicationprotectionintents + +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 RecoveryResourceGroupCustomDetails interface { + RecoveryResourceGroupCustomDetails() BaseRecoveryResourceGroupCustomDetailsImpl +} + +var _ RecoveryResourceGroupCustomDetails = BaseRecoveryResourceGroupCustomDetailsImpl{} + +type BaseRecoveryResourceGroupCustomDetailsImpl struct { + ResourceType string `json:"resourceType"` +} + +func (s BaseRecoveryResourceGroupCustomDetailsImpl) RecoveryResourceGroupCustomDetails() BaseRecoveryResourceGroupCustomDetailsImpl { + return s +} + +var _ RecoveryResourceGroupCustomDetails = RawRecoveryResourceGroupCustomDetailsImpl{} + +// RawRecoveryResourceGroupCustomDetailsImpl 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 RawRecoveryResourceGroupCustomDetailsImpl struct { + recoveryResourceGroupCustomDetails BaseRecoveryResourceGroupCustomDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryResourceGroupCustomDetailsImpl) RecoveryResourceGroupCustomDetails() BaseRecoveryResourceGroupCustomDetailsImpl { + return s.recoveryResourceGroupCustomDetails +} + +func UnmarshalRecoveryResourceGroupCustomDetailsImplementation(input []byte) (RecoveryResourceGroupCustomDetails, 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 RecoveryResourceGroupCustomDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["resourceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Existing") { + var out ExistingRecoveryRecoveryResourceGroup + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingRecoveryRecoveryResourceGroup: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryResourceGroupCustomDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryResourceGroupCustomDetailsImpl: %+v", err) + } + + return RawRecoveryResourceGroupCustomDetailsImpl{ + recoveryResourceGroupCustomDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_recoveryvirtualnetworkcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_recoveryvirtualnetworkcustomdetails.go new file mode 100644 index 00000000000..848cbc8806b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_recoveryvirtualnetworkcustomdetails.go @@ -0,0 +1,83 @@ +package replicationprotectionintents + +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 RecoveryVirtualNetworkCustomDetails interface { + RecoveryVirtualNetworkCustomDetails() BaseRecoveryVirtualNetworkCustomDetailsImpl +} + +var _ RecoveryVirtualNetworkCustomDetails = BaseRecoveryVirtualNetworkCustomDetailsImpl{} + +type BaseRecoveryVirtualNetworkCustomDetailsImpl struct { + ResourceType string `json:"resourceType"` +} + +func (s BaseRecoveryVirtualNetworkCustomDetailsImpl) RecoveryVirtualNetworkCustomDetails() BaseRecoveryVirtualNetworkCustomDetailsImpl { + return s +} + +var _ RecoveryVirtualNetworkCustomDetails = RawRecoveryVirtualNetworkCustomDetailsImpl{} + +// RawRecoveryVirtualNetworkCustomDetailsImpl 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 RawRecoveryVirtualNetworkCustomDetailsImpl struct { + recoveryVirtualNetworkCustomDetails BaseRecoveryVirtualNetworkCustomDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryVirtualNetworkCustomDetailsImpl) RecoveryVirtualNetworkCustomDetails() BaseRecoveryVirtualNetworkCustomDetailsImpl { + return s.recoveryVirtualNetworkCustomDetails +} + +func UnmarshalRecoveryVirtualNetworkCustomDetailsImplementation(input []byte) (RecoveryVirtualNetworkCustomDetails, 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 RecoveryVirtualNetworkCustomDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["resourceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Existing") { + var out ExistingRecoveryVirtualNetwork + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingRecoveryVirtualNetwork: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "New") { + var out NewRecoveryVirtualNetwork + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NewRecoveryVirtualNetwork: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryVirtualNetworkCustomDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryVirtualNetworkCustomDetailsImpl: %+v", err) + } + + return RawRecoveryVirtualNetworkCustomDetailsImpl{ + recoveryVirtualNetworkCustomDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_replicationprotectionintent.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_replicationprotectionintent.go new file mode 100644 index 00000000000..1fbffaaf5ab --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_replicationprotectionintent.go @@ -0,0 +1,12 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectionIntent struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReplicationProtectionIntentProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_replicationprotectionintentproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_replicationprotectionintentproperties.go new file mode 100644 index 00000000000..fcae31616b9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_replicationprotectionintentproperties.go @@ -0,0 +1,54 @@ +package replicationprotectionintents + +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 ReplicationProtectionIntentProperties struct { + CreationTimeUTC *string `json:"creationTimeUTC,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + JobId *string `json:"jobId,omitempty"` + JobState *string `json:"jobState,omitempty"` + ProviderSpecificDetails ReplicationProtectionIntentProviderSpecificSettings `json:"providerSpecificDetails"` +} + +var _ json.Unmarshaler = &ReplicationProtectionIntentProperties{} + +func (s *ReplicationProtectionIntentProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CreationTimeUTC *string `json:"creationTimeUTC,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + JobId *string `json:"jobId,omitempty"` + JobState *string `json:"jobState,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CreationTimeUTC = decoded.CreationTimeUTC + s.FriendlyName = decoded.FriendlyName + s.IsActive = decoded.IsActive + s.JobId = decoded.JobId + s.JobState = decoded.JobState + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ReplicationProtectionIntentProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + impl, err := UnmarshalReplicationProtectionIntentProviderSpecificSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'ReplicationProtectionIntentProperties': %+v", err) + } + s.ProviderSpecificDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_replicationprotectionintentproviderspecificsettings.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_replicationprotectionintentproviderspecificsettings.go new file mode 100644 index 00000000000..ca02cd47751 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_replicationprotectionintentproviderspecificsettings.go @@ -0,0 +1,75 @@ +package replicationprotectionintents + +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 ReplicationProtectionIntentProviderSpecificSettings interface { + ReplicationProtectionIntentProviderSpecificSettings() BaseReplicationProtectionIntentProviderSpecificSettingsImpl +} + +var _ ReplicationProtectionIntentProviderSpecificSettings = BaseReplicationProtectionIntentProviderSpecificSettingsImpl{} + +type BaseReplicationProtectionIntentProviderSpecificSettingsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseReplicationProtectionIntentProviderSpecificSettingsImpl) ReplicationProtectionIntentProviderSpecificSettings() BaseReplicationProtectionIntentProviderSpecificSettingsImpl { + return s +} + +var _ ReplicationProtectionIntentProviderSpecificSettings = RawReplicationProtectionIntentProviderSpecificSettingsImpl{} + +// RawReplicationProtectionIntentProviderSpecificSettingsImpl 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 RawReplicationProtectionIntentProviderSpecificSettingsImpl struct { + replicationProtectionIntentProviderSpecificSettings BaseReplicationProtectionIntentProviderSpecificSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawReplicationProtectionIntentProviderSpecificSettingsImpl) ReplicationProtectionIntentProviderSpecificSettings() BaseReplicationProtectionIntentProviderSpecificSettingsImpl { + return s.replicationProtectionIntentProviderSpecificSettings +} + +func UnmarshalReplicationProtectionIntentProviderSpecificSettingsImplementation(input []byte) (ReplicationProtectionIntentProviderSpecificSettings, 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 ReplicationProtectionIntentProviderSpecificSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out A2AReplicationIntentDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into A2AReplicationIntentDetails: %+v", err) + } + return out, nil + } + + var parent BaseReplicationProtectionIntentProviderSpecificSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseReplicationProtectionIntentProviderSpecificSettingsImpl: %+v", err) + } + + return RawReplicationProtectionIntentProviderSpecificSettingsImpl{ + replicationProtectionIntentProviderSpecificSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_storageaccountcustomdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_storageaccountcustomdetails.go new file mode 100644 index 00000000000..ca85a56b9f4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/model_storageaccountcustomdetails.go @@ -0,0 +1,75 @@ +package replicationprotectionintents + +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 StorageAccountCustomDetails interface { + StorageAccountCustomDetails() BaseStorageAccountCustomDetailsImpl +} + +var _ StorageAccountCustomDetails = BaseStorageAccountCustomDetailsImpl{} + +type BaseStorageAccountCustomDetailsImpl struct { + ResourceType string `json:"resourceType"` +} + +func (s BaseStorageAccountCustomDetailsImpl) StorageAccountCustomDetails() BaseStorageAccountCustomDetailsImpl { + return s +} + +var _ StorageAccountCustomDetails = RawStorageAccountCustomDetailsImpl{} + +// RawStorageAccountCustomDetailsImpl 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 RawStorageAccountCustomDetailsImpl struct { + storageAccountCustomDetails BaseStorageAccountCustomDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawStorageAccountCustomDetailsImpl) StorageAccountCustomDetails() BaseStorageAccountCustomDetailsImpl { + return s.storageAccountCustomDetails +} + +func UnmarshalStorageAccountCustomDetailsImplementation(input []byte) (StorageAccountCustomDetails, 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 StorageAccountCustomDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["resourceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Existing") { + var out ExistingStorageAccount + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ExistingStorageAccount: %+v", err) + } + return out, nil + } + + var parent BaseStorageAccountCustomDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseStorageAccountCustomDetailsImpl: %+v", err) + } + + return RawStorageAccountCustomDetailsImpl{ + storageAccountCustomDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/predicates.go new file mode 100644 index 00000000000..9a372249403 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/predicates.go @@ -0,0 +1,32 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationProtectionIntentOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ReplicationProtectionIntentOperationPredicate) Matches(input ReplicationProtectionIntent) 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/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/version.go new file mode 100644 index 00000000000..d6dfdc3910e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationprotectionintents/version.go @@ -0,0 +1,10 @@ +package replicationprotectionintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationprotectionintents/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/README.md new file mode 100644 index 00000000000..6a23e4a2150 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/README.md @@ -0,0 +1,203 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans` Documentation + +The `replicationrecoveryplans` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans" +``` + + +### Client Initialization + +```go +client := replicationrecoveryplans.NewReplicationRecoveryPlansClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Create` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +payload := replicationrecoveryplans.CreateRecoveryPlanInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Delete` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.FailoverCancel` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +if err := client.FailoverCancelThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.FailoverCommit` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +if err := client.FailoverCommitThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Get` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +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: `ReplicationRecoveryPlansClient.List` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// 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: `ReplicationRecoveryPlansClient.PlannedFailover` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +payload := replicationrecoveryplans.RecoveryPlanPlannedFailoverInput{ + // ... +} + + +if err := client.PlannedFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Reprotect` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +if err := client.ReprotectThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.TestFailover` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +payload := replicationrecoveryplans.RecoveryPlanTestFailoverInput{ + // ... +} + + +if err := client.TestFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.TestFailoverCleanup` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +payload := replicationrecoveryplans.RecoveryPlanTestFailoverCleanupInput{ + // ... +} + + +if err := client.TestFailoverCleanupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.UnplannedFailover` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +payload := replicationrecoveryplans.RecoveryPlanUnplannedFailoverInput{ + // ... +} + + +if err := client.UnplannedFailoverThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryPlansClient.Update` + +```go +ctx := context.TODO() +id := replicationrecoveryplans.NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + +payload := replicationrecoveryplans.UpdateRecoveryPlanInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/client.go new file mode 100644 index 00000000000..3337fa87cfc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/client.go @@ -0,0 +1,26 @@ +package replicationrecoveryplans + +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 ReplicationRecoveryPlansClient struct { + Client *resourcemanager.Client +} + +func NewReplicationRecoveryPlansClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationRecoveryPlansClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationrecoveryplans", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationRecoveryPlansClient: %+v", err) + } + + return &ReplicationRecoveryPlansClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/constants.go new file mode 100644 index 00000000000..3205b305372 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/constants.go @@ -0,0 +1,691 @@ +package replicationrecoveryplans + +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 A2ARpRecoveryPointType string + +const ( + A2ARpRecoveryPointTypeLatest A2ARpRecoveryPointType = "Latest" + A2ARpRecoveryPointTypeLatestApplicationConsistent A2ARpRecoveryPointType = "LatestApplicationConsistent" + A2ARpRecoveryPointTypeLatestCrashConsistent A2ARpRecoveryPointType = "LatestCrashConsistent" + A2ARpRecoveryPointTypeLatestProcessed A2ARpRecoveryPointType = "LatestProcessed" +) + +func PossibleValuesForA2ARpRecoveryPointType() []string { + return []string{ + string(A2ARpRecoveryPointTypeLatest), + string(A2ARpRecoveryPointTypeLatestApplicationConsistent), + string(A2ARpRecoveryPointTypeLatestCrashConsistent), + string(A2ARpRecoveryPointTypeLatestProcessed), + } +} + +func (s *A2ARpRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseA2ARpRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseA2ARpRecoveryPointType(input string) (*A2ARpRecoveryPointType, error) { + vals := map[string]A2ARpRecoveryPointType{ + "latest": A2ARpRecoveryPointTypeLatest, + "latestapplicationconsistent": A2ARpRecoveryPointTypeLatestApplicationConsistent, + "latestcrashconsistent": A2ARpRecoveryPointTypeLatestCrashConsistent, + "latestprocessed": A2ARpRecoveryPointTypeLatestProcessed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := A2ARpRecoveryPointType(input) + return &out, nil +} + +type AlternateLocationRecoveryOption string + +const ( + AlternateLocationRecoveryOptionCreateVMIfNotFound AlternateLocationRecoveryOption = "CreateVmIfNotFound" + AlternateLocationRecoveryOptionNoAction AlternateLocationRecoveryOption = "NoAction" +) + +func PossibleValuesForAlternateLocationRecoveryOption() []string { + return []string{ + string(AlternateLocationRecoveryOptionCreateVMIfNotFound), + string(AlternateLocationRecoveryOptionNoAction), + } +} + +func (s *AlternateLocationRecoveryOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAlternateLocationRecoveryOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAlternateLocationRecoveryOption(input string) (*AlternateLocationRecoveryOption, error) { + vals := map[string]AlternateLocationRecoveryOption{ + "createvmifnotfound": AlternateLocationRecoveryOptionCreateVMIfNotFound, + "noaction": AlternateLocationRecoveryOptionNoAction, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AlternateLocationRecoveryOption(input) + return &out, nil +} + +type DataSyncStatus string + +const ( + DataSyncStatusForDownTime DataSyncStatus = "ForDownTime" + DataSyncStatusForSynchronization DataSyncStatus = "ForSynchronization" +) + +func PossibleValuesForDataSyncStatus() []string { + return []string{ + string(DataSyncStatusForDownTime), + string(DataSyncStatusForSynchronization), + } +} + +func (s *DataSyncStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataSyncStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataSyncStatus(input string) (*DataSyncStatus, error) { + vals := map[string]DataSyncStatus{ + "fordowntime": DataSyncStatusForDownTime, + "forsynchronization": DataSyncStatusForSynchronization, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataSyncStatus(input) + return &out, nil +} + +type FailoverDeploymentModel string + +const ( + FailoverDeploymentModelClassic FailoverDeploymentModel = "Classic" + FailoverDeploymentModelNotApplicable FailoverDeploymentModel = "NotApplicable" + FailoverDeploymentModelResourceManager FailoverDeploymentModel = "ResourceManager" +) + +func PossibleValuesForFailoverDeploymentModel() []string { + return []string{ + string(FailoverDeploymentModelClassic), + string(FailoverDeploymentModelNotApplicable), + string(FailoverDeploymentModelResourceManager), + } +} + +func (s *FailoverDeploymentModel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailoverDeploymentModel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFailoverDeploymentModel(input string) (*FailoverDeploymentModel, error) { + vals := map[string]FailoverDeploymentModel{ + "classic": FailoverDeploymentModelClassic, + "notapplicable": FailoverDeploymentModelNotApplicable, + "resourcemanager": FailoverDeploymentModelResourceManager, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FailoverDeploymentModel(input) + return &out, nil +} + +type HyperVReplicaAzureRpRecoveryPointType string + +const ( + HyperVReplicaAzureRpRecoveryPointTypeLatest HyperVReplicaAzureRpRecoveryPointType = "Latest" + HyperVReplicaAzureRpRecoveryPointTypeLatestApplicationConsistent HyperVReplicaAzureRpRecoveryPointType = "LatestApplicationConsistent" + HyperVReplicaAzureRpRecoveryPointTypeLatestProcessed HyperVReplicaAzureRpRecoveryPointType = "LatestProcessed" +) + +func PossibleValuesForHyperVReplicaAzureRpRecoveryPointType() []string { + return []string{ + string(HyperVReplicaAzureRpRecoveryPointTypeLatest), + string(HyperVReplicaAzureRpRecoveryPointTypeLatestApplicationConsistent), + string(HyperVReplicaAzureRpRecoveryPointTypeLatestProcessed), + } +} + +func (s *HyperVReplicaAzureRpRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHyperVReplicaAzureRpRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHyperVReplicaAzureRpRecoveryPointType(input string) (*HyperVReplicaAzureRpRecoveryPointType, error) { + vals := map[string]HyperVReplicaAzureRpRecoveryPointType{ + "latest": HyperVReplicaAzureRpRecoveryPointTypeLatest, + "latestapplicationconsistent": HyperVReplicaAzureRpRecoveryPointTypeLatestApplicationConsistent, + "latestprocessed": HyperVReplicaAzureRpRecoveryPointTypeLatestProcessed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HyperVReplicaAzureRpRecoveryPointType(input) + return &out, nil +} + +type InMageRcmFailbackRecoveryPointType string + +const ( + InMageRcmFailbackRecoveryPointTypeApplicationConsistent InMageRcmFailbackRecoveryPointType = "ApplicationConsistent" + InMageRcmFailbackRecoveryPointTypeCrashConsistent InMageRcmFailbackRecoveryPointType = "CrashConsistent" +) + +func PossibleValuesForInMageRcmFailbackRecoveryPointType() []string { + return []string{ + string(InMageRcmFailbackRecoveryPointTypeApplicationConsistent), + string(InMageRcmFailbackRecoveryPointTypeCrashConsistent), + } +} + +func (s *InMageRcmFailbackRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInMageRcmFailbackRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInMageRcmFailbackRecoveryPointType(input string) (*InMageRcmFailbackRecoveryPointType, error) { + vals := map[string]InMageRcmFailbackRecoveryPointType{ + "applicationconsistent": InMageRcmFailbackRecoveryPointTypeApplicationConsistent, + "crashconsistent": InMageRcmFailbackRecoveryPointTypeCrashConsistent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InMageRcmFailbackRecoveryPointType(input) + return &out, nil +} + +type InMageV2RpRecoveryPointType string + +const ( + InMageV2RpRecoveryPointTypeLatest InMageV2RpRecoveryPointType = "Latest" + InMageV2RpRecoveryPointTypeLatestApplicationConsistent InMageV2RpRecoveryPointType = "LatestApplicationConsistent" + InMageV2RpRecoveryPointTypeLatestCrashConsistent InMageV2RpRecoveryPointType = "LatestCrashConsistent" + InMageV2RpRecoveryPointTypeLatestProcessed InMageV2RpRecoveryPointType = "LatestProcessed" +) + +func PossibleValuesForInMageV2RpRecoveryPointType() []string { + return []string{ + string(InMageV2RpRecoveryPointTypeLatest), + string(InMageV2RpRecoveryPointTypeLatestApplicationConsistent), + string(InMageV2RpRecoveryPointTypeLatestCrashConsistent), + string(InMageV2RpRecoveryPointTypeLatestProcessed), + } +} + +func (s *InMageV2RpRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInMageV2RpRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInMageV2RpRecoveryPointType(input string) (*InMageV2RpRecoveryPointType, error) { + vals := map[string]InMageV2RpRecoveryPointType{ + "latest": InMageV2RpRecoveryPointTypeLatest, + "latestapplicationconsistent": InMageV2RpRecoveryPointTypeLatestApplicationConsistent, + "latestcrashconsistent": InMageV2RpRecoveryPointTypeLatestCrashConsistent, + "latestprocessed": InMageV2RpRecoveryPointTypeLatestProcessed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InMageV2RpRecoveryPointType(input) + return &out, nil +} + +type MultiVMSyncPointOption string + +const ( + MultiVMSyncPointOptionUseMultiVMSyncRecoveryPoint MultiVMSyncPointOption = "UseMultiVmSyncRecoveryPoint" + MultiVMSyncPointOptionUsePerVMRecoveryPoint MultiVMSyncPointOption = "UsePerVmRecoveryPoint" +) + +func PossibleValuesForMultiVMSyncPointOption() []string { + return []string{ + string(MultiVMSyncPointOptionUseMultiVMSyncRecoveryPoint), + string(MultiVMSyncPointOptionUsePerVMRecoveryPoint), + } +} + +func (s *MultiVMSyncPointOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMultiVMSyncPointOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMultiVMSyncPointOption(input string) (*MultiVMSyncPointOption, error) { + vals := map[string]MultiVMSyncPointOption{ + "usemultivmsyncrecoverypoint": MultiVMSyncPointOptionUseMultiVMSyncRecoveryPoint, + "usepervmrecoverypoint": MultiVMSyncPointOptionUsePerVMRecoveryPoint, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MultiVMSyncPointOption(input) + return &out, nil +} + +type PossibleOperationsDirections string + +const ( + PossibleOperationsDirectionsPrimaryToRecovery PossibleOperationsDirections = "PrimaryToRecovery" + PossibleOperationsDirectionsRecoveryToPrimary PossibleOperationsDirections = "RecoveryToPrimary" +) + +func PossibleValuesForPossibleOperationsDirections() []string { + return []string{ + string(PossibleOperationsDirectionsPrimaryToRecovery), + string(PossibleOperationsDirectionsRecoveryToPrimary), + } +} + +func (s *PossibleOperationsDirections) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePossibleOperationsDirections(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePossibleOperationsDirections(input string) (*PossibleOperationsDirections, error) { + vals := map[string]PossibleOperationsDirections{ + "primarytorecovery": PossibleOperationsDirectionsPrimaryToRecovery, + "recoverytoprimary": PossibleOperationsDirectionsRecoveryToPrimary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PossibleOperationsDirections(input) + return &out, nil +} + +type RecoveryPlanActionLocation string + +const ( + RecoveryPlanActionLocationPrimary RecoveryPlanActionLocation = "Primary" + RecoveryPlanActionLocationRecovery RecoveryPlanActionLocation = "Recovery" +) + +func PossibleValuesForRecoveryPlanActionLocation() []string { + return []string{ + string(RecoveryPlanActionLocationPrimary), + string(RecoveryPlanActionLocationRecovery), + } +} + +func (s *RecoveryPlanActionLocation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPlanActionLocation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPlanActionLocation(input string) (*RecoveryPlanActionLocation, error) { + vals := map[string]RecoveryPlanActionLocation{ + "primary": RecoveryPlanActionLocationPrimary, + "recovery": RecoveryPlanActionLocationRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPlanActionLocation(input) + return &out, nil +} + +type RecoveryPlanGroupType string + +const ( + RecoveryPlanGroupTypeBoot RecoveryPlanGroupType = "Boot" + RecoveryPlanGroupTypeFailover RecoveryPlanGroupType = "Failover" + RecoveryPlanGroupTypeShutdown RecoveryPlanGroupType = "Shutdown" +) + +func PossibleValuesForRecoveryPlanGroupType() []string { + return []string{ + string(RecoveryPlanGroupTypeBoot), + string(RecoveryPlanGroupTypeFailover), + string(RecoveryPlanGroupTypeShutdown), + } +} + +func (s *RecoveryPlanGroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPlanGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPlanGroupType(input string) (*RecoveryPlanGroupType, error) { + vals := map[string]RecoveryPlanGroupType{ + "boot": RecoveryPlanGroupTypeBoot, + "failover": RecoveryPlanGroupTypeFailover, + "shutdown": RecoveryPlanGroupTypeShutdown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPlanGroupType(input) + return &out, nil +} + +type RecoveryPlanPointType string + +const ( + RecoveryPlanPointTypeLatest RecoveryPlanPointType = "Latest" + RecoveryPlanPointTypeLatestApplicationConsistent RecoveryPlanPointType = "LatestApplicationConsistent" + RecoveryPlanPointTypeLatestCrashConsistent RecoveryPlanPointType = "LatestCrashConsistent" + RecoveryPlanPointTypeLatestProcessed RecoveryPlanPointType = "LatestProcessed" +) + +func PossibleValuesForRecoveryPlanPointType() []string { + return []string{ + string(RecoveryPlanPointTypeLatest), + string(RecoveryPlanPointTypeLatestApplicationConsistent), + string(RecoveryPlanPointTypeLatestCrashConsistent), + string(RecoveryPlanPointTypeLatestProcessed), + } +} + +func (s *RecoveryPlanPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPlanPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPlanPointType(input string) (*RecoveryPlanPointType, error) { + vals := map[string]RecoveryPlanPointType{ + "latest": RecoveryPlanPointTypeLatest, + "latestapplicationconsistent": RecoveryPlanPointTypeLatestApplicationConsistent, + "latestcrashconsistent": RecoveryPlanPointTypeLatestCrashConsistent, + "latestprocessed": RecoveryPlanPointTypeLatestProcessed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPlanPointType(input) + return &out, nil +} + +type ReplicationProtectedItemOperation string + +const ( + ReplicationProtectedItemOperationCancelFailover ReplicationProtectedItemOperation = "CancelFailover" + ReplicationProtectedItemOperationChangePit ReplicationProtectedItemOperation = "ChangePit" + ReplicationProtectedItemOperationCommit ReplicationProtectedItemOperation = "Commit" + ReplicationProtectedItemOperationCompleteMigration ReplicationProtectedItemOperation = "CompleteMigration" + ReplicationProtectedItemOperationDisableProtection ReplicationProtectedItemOperation = "DisableProtection" + ReplicationProtectedItemOperationFailback ReplicationProtectedItemOperation = "Failback" + ReplicationProtectedItemOperationFinalizeFailback ReplicationProtectedItemOperation = "FinalizeFailback" + ReplicationProtectedItemOperationPlannedFailover ReplicationProtectedItemOperation = "PlannedFailover" + ReplicationProtectedItemOperationRepairReplication ReplicationProtectedItemOperation = "RepairReplication" + ReplicationProtectedItemOperationReverseReplicate ReplicationProtectedItemOperation = "ReverseReplicate" + ReplicationProtectedItemOperationSwitchProtection ReplicationProtectedItemOperation = "SwitchProtection" + ReplicationProtectedItemOperationTestFailover ReplicationProtectedItemOperation = "TestFailover" + ReplicationProtectedItemOperationTestFailoverCleanup ReplicationProtectedItemOperation = "TestFailoverCleanup" + ReplicationProtectedItemOperationUnplannedFailover ReplicationProtectedItemOperation = "UnplannedFailover" +) + +func PossibleValuesForReplicationProtectedItemOperation() []string { + return []string{ + string(ReplicationProtectedItemOperationCancelFailover), + string(ReplicationProtectedItemOperationChangePit), + string(ReplicationProtectedItemOperationCommit), + string(ReplicationProtectedItemOperationCompleteMigration), + string(ReplicationProtectedItemOperationDisableProtection), + string(ReplicationProtectedItemOperationFailback), + string(ReplicationProtectedItemOperationFinalizeFailback), + string(ReplicationProtectedItemOperationPlannedFailover), + string(ReplicationProtectedItemOperationRepairReplication), + string(ReplicationProtectedItemOperationReverseReplicate), + string(ReplicationProtectedItemOperationSwitchProtection), + string(ReplicationProtectedItemOperationTestFailover), + string(ReplicationProtectedItemOperationTestFailoverCleanup), + string(ReplicationProtectedItemOperationUnplannedFailover), + } +} + +func (s *ReplicationProtectedItemOperation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationProtectedItemOperation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReplicationProtectedItemOperation(input string) (*ReplicationProtectedItemOperation, error) { + vals := map[string]ReplicationProtectedItemOperation{ + "cancelfailover": ReplicationProtectedItemOperationCancelFailover, + "changepit": ReplicationProtectedItemOperationChangePit, + "commit": ReplicationProtectedItemOperationCommit, + "completemigration": ReplicationProtectedItemOperationCompleteMigration, + "disableprotection": ReplicationProtectedItemOperationDisableProtection, + "failback": ReplicationProtectedItemOperationFailback, + "finalizefailback": ReplicationProtectedItemOperationFinalizeFailback, + "plannedfailover": ReplicationProtectedItemOperationPlannedFailover, + "repairreplication": ReplicationProtectedItemOperationRepairReplication, + "reversereplicate": ReplicationProtectedItemOperationReverseReplicate, + "switchprotection": ReplicationProtectedItemOperationSwitchProtection, + "testfailover": ReplicationProtectedItemOperationTestFailover, + "testfailovercleanup": ReplicationProtectedItemOperationTestFailoverCleanup, + "unplannedfailover": ReplicationProtectedItemOperationUnplannedFailover, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReplicationProtectedItemOperation(input) + return &out, nil +} + +type RpInMageRecoveryPointType string + +const ( + RpInMageRecoveryPointTypeCustom RpInMageRecoveryPointType = "Custom" + RpInMageRecoveryPointTypeLatestTag RpInMageRecoveryPointType = "LatestTag" + RpInMageRecoveryPointTypeLatestTime RpInMageRecoveryPointType = "LatestTime" +) + +func PossibleValuesForRpInMageRecoveryPointType() []string { + return []string{ + string(RpInMageRecoveryPointTypeCustom), + string(RpInMageRecoveryPointTypeLatestTag), + string(RpInMageRecoveryPointTypeLatestTime), + } +} + +func (s *RpInMageRecoveryPointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRpInMageRecoveryPointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRpInMageRecoveryPointType(input string) (*RpInMageRecoveryPointType, error) { + vals := map[string]RpInMageRecoveryPointType{ + "custom": RpInMageRecoveryPointTypeCustom, + "latesttag": RpInMageRecoveryPointTypeLatestTag, + "latesttime": RpInMageRecoveryPointTypeLatestTime, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RpInMageRecoveryPointType(input) + return &out, nil +} + +type SourceSiteOperations string + +const ( + SourceSiteOperationsNotRequired SourceSiteOperations = "NotRequired" + SourceSiteOperationsRequired SourceSiteOperations = "Required" +) + +func PossibleValuesForSourceSiteOperations() []string { + return []string{ + string(SourceSiteOperationsNotRequired), + string(SourceSiteOperationsRequired), + } +} + +func (s *SourceSiteOperations) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSourceSiteOperations(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSourceSiteOperations(input string) (*SourceSiteOperations, error) { + vals := map[string]SourceSiteOperations{ + "notrequired": SourceSiteOperationsNotRequired, + "required": SourceSiteOperationsRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SourceSiteOperations(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/id_replicationrecoveryplan.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/id_replicationrecoveryplan.go new file mode 100644 index 00000000000..02aef0ff679 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/id_replicationrecoveryplan.go @@ -0,0 +1,139 @@ +package replicationrecoveryplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationRecoveryPlanId{}) +} + +var _ resourceids.ResourceId = &ReplicationRecoveryPlanId{} + +// ReplicationRecoveryPlanId is a struct representing the Resource ID for a Replication Recovery Plan +type ReplicationRecoveryPlanId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationRecoveryPlanName string +} + +// NewReplicationRecoveryPlanID returns a new ReplicationRecoveryPlanId struct +func NewReplicationRecoveryPlanID(subscriptionId string, resourceGroupName string, vaultName string, replicationRecoveryPlanName string) ReplicationRecoveryPlanId { + return ReplicationRecoveryPlanId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationRecoveryPlanName: replicationRecoveryPlanName, + } +} + +// ParseReplicationRecoveryPlanID parses 'input' into a ReplicationRecoveryPlanId +func ParseReplicationRecoveryPlanID(input string) (*ReplicationRecoveryPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationRecoveryPlanId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationRecoveryPlanId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationRecoveryPlanIDInsensitively parses 'input' case-insensitively into a ReplicationRecoveryPlanId +// note: this method should only be used for API response data and not user input +func ParseReplicationRecoveryPlanIDInsensitively(input string) (*ReplicationRecoveryPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationRecoveryPlanId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationRecoveryPlanId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationRecoveryPlanId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationRecoveryPlanName, ok = input.Parsed["replicationRecoveryPlanName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationRecoveryPlanName", input) + } + + return nil +} + +// ValidateReplicationRecoveryPlanID checks that 'input' can be parsed as a Replication Recovery Plan ID +func ValidateReplicationRecoveryPlanID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationRecoveryPlanID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Recovery Plan ID +func (id ReplicationRecoveryPlanId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationRecoveryPlans/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationRecoveryPlanName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Recovery Plan ID +func (id ReplicationRecoveryPlanId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationRecoveryPlans", "replicationRecoveryPlans", "replicationRecoveryPlans"), + resourceids.UserSpecifiedSegment("replicationRecoveryPlanName", "replicationRecoveryPlanName"), + } +} + +// String returns a human-readable description of this Replication Recovery Plan ID +func (id ReplicationRecoveryPlanId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Recovery Plan Name: %q", id.ReplicationRecoveryPlanName), + } + return fmt.Sprintf("Replication Recovery Plan (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/id_replicationrecoveryplan_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/id_replicationrecoveryplan_test.go new file mode 100644 index 00000000000..64c0aac5f20 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/id_replicationrecoveryplan_test.go @@ -0,0 +1,327 @@ +package replicationrecoveryplans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationRecoveryPlanId{} + +func TestNewReplicationRecoveryPlanID(t *testing.T) { + id := NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationRecoveryPlanName != "replicationRecoveryPlanName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationRecoveryPlanName'", id.ReplicationRecoveryPlanName, "replicationRecoveryPlanName") + } +} + +func TestFormatReplicationRecoveryPlanID(t *testing.T) { + actual := NewReplicationRecoveryPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationRecoveryPlanName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans/replicationRecoveryPlanName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationRecoveryPlanID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationRecoveryPlanId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans/replicationRecoveryPlanName", + Expected: &ReplicationRecoveryPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationRecoveryPlanName: "replicationRecoveryPlanName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans/replicationRecoveryPlanName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationRecoveryPlanID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationRecoveryPlanName != v.Expected.ReplicationRecoveryPlanName { + t.Fatalf("Expected %q but got %q for ReplicationRecoveryPlanName", v.Expected.ReplicationRecoveryPlanName, actual.ReplicationRecoveryPlanName) + } + + } +} + +func TestParseReplicationRecoveryPlanIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationRecoveryPlanId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnReCoVeRyPlAnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans/replicationRecoveryPlanName", + Expected: &ReplicationRecoveryPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationRecoveryPlanName: "replicationRecoveryPlanName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans/replicationRecoveryPlanName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnReCoVeRyPlAnS/rEpLiCaTiOnReCoVeRyPlAnNaMe", + Expected: &ReplicationRecoveryPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationRecoveryPlanName: "rEpLiCaTiOnReCoVeRyPlAnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnReCoVeRyPlAnS/rEpLiCaTiOnReCoVeRyPlAnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationRecoveryPlanIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationRecoveryPlanName != v.Expected.ReplicationRecoveryPlanName { + t.Fatalf("Expected %q but got %q for ReplicationRecoveryPlanName", v.Expected.ReplicationRecoveryPlanName, actual.ReplicationRecoveryPlanName) + } + + } +} + +func TestSegmentsForReplicationRecoveryPlanId(t *testing.T) { + segments := ReplicationRecoveryPlanId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationRecoveryPlanId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/id_vault.go new file mode 100644 index 00000000000..634bd8573b8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/id_vault.go @@ -0,0 +1,130 @@ +package replicationrecoveryplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/id_vault_test.go new file mode 100644 index 00000000000..3f67d09bb04 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationrecoveryplans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_create.go new file mode 100644 index 00000000000..208bd2e921a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_create.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *RecoveryPlan +} + +// Create ... +func (c ReplicationRecoveryPlansClient) Create(ctx context.Context, id ReplicationRecoveryPlanId, input CreateRecoveryPlanInput) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationRecoveryPlansClient) CreateThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input CreateRecoveryPlanInput) 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/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_delete.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_delete.go new file mode 100644 index 00000000000..361ccfa4989 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_delete.go @@ -0,0 +1,70 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 ReplicationRecoveryPlansClient) Delete(ctx context.Context, id ReplicationRecoveryPlanId) (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 ReplicationRecoveryPlansClient) DeleteThenPoll(ctx context.Context, id ReplicationRecoveryPlanId) 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/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_failovercancel.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_failovercancel.go new file mode 100644 index 00000000000..cdd458efe6e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_failovercancel.go @@ -0,0 +1,71 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverCancelOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// FailoverCancel ... +func (c ReplicationRecoveryPlansClient) FailoverCancel(ctx context.Context, id ReplicationRecoveryPlanId) (result FailoverCancelOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverCancel", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// FailoverCancelThenPoll performs FailoverCancel then polls until it's completed +func (c ReplicationRecoveryPlansClient) FailoverCancelThenPoll(ctx context.Context, id ReplicationRecoveryPlanId) error { + result, err := c.FailoverCancel(ctx, id) + if err != nil { + return fmt.Errorf("performing FailoverCancel: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FailoverCancel: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_failovercommit.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_failovercommit.go new file mode 100644 index 00000000000..616be805c7c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_failovercommit.go @@ -0,0 +1,71 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverCommitOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// FailoverCommit ... +func (c ReplicationRecoveryPlansClient) FailoverCommit(ctx context.Context, id ReplicationRecoveryPlanId) (result FailoverCommitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failoverCommit", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// FailoverCommitThenPoll performs FailoverCommit then polls until it's completed +func (c ReplicationRecoveryPlansClient) FailoverCommitThenPoll(ctx context.Context, id ReplicationRecoveryPlanId) error { + result, err := c.FailoverCommit(ctx, id) + if err != nil { + return fmt.Errorf("performing FailoverCommit: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FailoverCommit: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_get.go new file mode 100644 index 00000000000..3bb61627501 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_get.go @@ -0,0 +1,53 @@ +package replicationrecoveryplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *RecoveryPlan +} + +// Get ... +func (c ReplicationRecoveryPlansClient) Get(ctx context.Context, id ReplicationRecoveryPlanId) (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 RecoveryPlan + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_list.go new file mode 100644 index 00000000000..d8446f2ae10 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_list.go @@ -0,0 +1,105 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]RecoveryPlan +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RecoveryPlan +} + +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 ReplicationRecoveryPlansClient) List(ctx context.Context, id VaultId) (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/replicationRecoveryPlans", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RecoveryPlan `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 ReplicationRecoveryPlansClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RecoveryPlanOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationRecoveryPlansClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate RecoveryPlanOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RecoveryPlan, 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/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_plannedfailover.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_plannedfailover.go new file mode 100644 index 00000000000..9e199f4febe --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_plannedfailover.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PlannedFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// PlannedFailover ... +func (c ReplicationRecoveryPlansClient) PlannedFailover(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanPlannedFailoverInput) (result PlannedFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/plannedFailover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PlannedFailoverThenPoll performs PlannedFailover then polls until it's completed +func (c ReplicationRecoveryPlansClient) PlannedFailoverThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanPlannedFailoverInput) error { + result, err := c.PlannedFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PlannedFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PlannedFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_reprotect.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_reprotect.go new file mode 100644 index 00000000000..4ba2693d77c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_reprotect.go @@ -0,0 +1,71 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReprotectOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// Reprotect ... +func (c ReplicationRecoveryPlansClient) Reprotect(ctx context.Context, id ReplicationRecoveryPlanId) (result ReprotectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reProtect", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReprotectThenPoll performs Reprotect then polls until it's completed +func (c ReplicationRecoveryPlansClient) ReprotectThenPoll(ctx context.Context, id ReplicationRecoveryPlanId) error { + result, err := c.Reprotect(ctx, id) + if err != nil { + return fmt.Errorf("performing Reprotect: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reprotect: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_testfailover.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_testfailover.go new file mode 100644 index 00000000000..5ce4c216166 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_testfailover.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// TestFailover ... +func (c ReplicationRecoveryPlansClient) TestFailover(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanTestFailoverInput) (result TestFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// TestFailoverThenPoll performs TestFailover then polls until it's completed +func (c ReplicationRecoveryPlansClient) TestFailoverThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanTestFailoverInput) error { + result, err := c.TestFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_testfailovercleanup.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_testfailovercleanup.go new file mode 100644 index 00000000000..77c89a02297 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_testfailovercleanup.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestFailoverCleanupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// TestFailoverCleanup ... +func (c ReplicationRecoveryPlansClient) TestFailoverCleanup(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanTestFailoverCleanupInput) (result TestFailoverCleanupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testFailoverCleanup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// TestFailoverCleanupThenPoll performs TestFailoverCleanup then polls until it's completed +func (c ReplicationRecoveryPlansClient) TestFailoverCleanupThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanTestFailoverCleanupInput) error { + result, err := c.TestFailoverCleanup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TestFailoverCleanup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TestFailoverCleanup: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_unplannedfailover.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_unplannedfailover.go new file mode 100644 index 00000000000..a2c4fe6c90d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_unplannedfailover.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnplannedFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryPlan +} + +// UnplannedFailover ... +func (c ReplicationRecoveryPlansClient) UnplannedFailover(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanUnplannedFailoverInput) (result UnplannedFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/unplannedFailover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UnplannedFailoverThenPoll performs UnplannedFailover then polls until it's completed +func (c ReplicationRecoveryPlansClient) UnplannedFailoverThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input RecoveryPlanUnplannedFailoverInput) error { + result, err := c.UnplannedFailover(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UnplannedFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UnplannedFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_update.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_update.go new file mode 100644 index 00000000000..45c17f2850c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/method_update.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *RecoveryPlan +} + +// Update ... +func (c ReplicationRecoveryPlansClient) Update(ctx context.Context, id ReplicationRecoveryPlanId, input UpdateRecoveryPlanInput) (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 ReplicationRecoveryPlansClient) UpdateThenPoll(ctx context.Context, id ReplicationRecoveryPlanId, input UpdateRecoveryPlanInput) 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/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_createrecoveryplaninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_createrecoveryplaninput.go new file mode 100644 index 00000000000..283b7b90f39 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_createrecoveryplaninput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateRecoveryPlanInput struct { + Properties CreateRecoveryPlanInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_createrecoveryplaninputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_createrecoveryplaninputproperties.go new file mode 100644 index 00000000000..c0779757fd4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_createrecoveryplaninputproperties.go @@ -0,0 +1,60 @@ +package replicationrecoveryplans + +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 CreateRecoveryPlanInputProperties struct { + FailoverDeploymentModel *FailoverDeploymentModel `json:"failoverDeploymentModel,omitempty"` + Groups []RecoveryPlanGroup `json:"groups"` + PrimaryFabricId string `json:"primaryFabricId"` + ProviderSpecificInput *[]RecoveryPlanProviderSpecificInput `json:"providerSpecificInput,omitempty"` + RecoveryFabricId string `json:"recoveryFabricId"` +} + +var _ json.Unmarshaler = &CreateRecoveryPlanInputProperties{} + +func (s *CreateRecoveryPlanInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDeploymentModel *FailoverDeploymentModel `json:"failoverDeploymentModel,omitempty"` + Groups []RecoveryPlanGroup `json:"groups"` + PrimaryFabricId string `json:"primaryFabricId"` + RecoveryFabricId string `json:"recoveryFabricId"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDeploymentModel = decoded.FailoverDeploymentModel + s.Groups = decoded.Groups + s.PrimaryFabricId = decoded.PrimaryFabricId + s.RecoveryFabricId = decoded.RecoveryFabricId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CreateRecoveryPlanInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificInput"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificInput into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificInput, 0) + for i, val := range listTemp { + impl, err := UnmarshalRecoveryPlanProviderSpecificInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificInput' for 'CreateRecoveryPlanInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificInput = &output + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_currentscenariodetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_currentscenariodetails.go new file mode 100644 index 00000000000..fbcd02e69f9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_currentscenariodetails.go @@ -0,0 +1,28 @@ +package replicationrecoveryplans + +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 CurrentScenarioDetails struct { + JobId *string `json:"jobId,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *CurrentScenarioDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CurrentScenarioDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplan.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplan.go new file mode 100644 index 00000000000..f2f8f5ac73f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplan.go @@ -0,0 +1,12 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlan struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecoveryPlanProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplana2adetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplana2adetails.go new file mode 100644 index 00000000000..67f3a9adf65 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplana2adetails.go @@ -0,0 +1,55 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificDetails = RecoveryPlanA2ADetails{} + +type RecoveryPlanA2ADetails struct { + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + PrimaryZone *string `json:"primaryZone,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryZone *string `json:"recoveryZone,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificDetails + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanA2ADetails) RecoveryPlanProviderSpecificDetails() BaseRecoveryPlanProviderSpecificDetailsImpl { + return BaseRecoveryPlanProviderSpecificDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanA2ADetails{} + +func (s RecoveryPlanA2ADetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanA2ADetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanA2ADetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanA2ADetails: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanA2ADetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplana2afailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplana2afailoverinput.go new file mode 100644 index 00000000000..a33bb19bdc1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplana2afailoverinput.go @@ -0,0 +1,52 @@ +package replicationrecoveryplans + +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 _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanA2AFailoverInput{} + +type RecoveryPlanA2AFailoverInput struct { + CloudServiceCreationOption *string `json:"cloudServiceCreationOption,omitempty"` + MultiVMSyncPointOption *MultiVMSyncPointOption `json:"multiVmSyncPointOption,omitempty"` + RecoveryPointType A2ARpRecoveryPointType `json:"recoveryPointType"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanA2AFailoverInput) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return BaseRecoveryPlanProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanA2AFailoverInput{} + +func (s RecoveryPlanA2AFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanA2AFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanA2AFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanA2AFailoverInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanA2AFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplana2ainput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplana2ainput.go new file mode 100644 index 00000000000..3768e22d457 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplana2ainput.go @@ -0,0 +1,55 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPlanProviderSpecificInput = RecoveryPlanA2AInput{} + +type RecoveryPlanA2AInput struct { + PrimaryExtendedLocation *edgezones.Model `json:"primaryExtendedLocation,omitempty"` + PrimaryZone *string `json:"primaryZone,omitempty"` + RecoveryExtendedLocation *edgezones.Model `json:"recoveryExtendedLocation,omitempty"` + RecoveryZone *string `json:"recoveryZone,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanA2AInput) RecoveryPlanProviderSpecificInput() BaseRecoveryPlanProviderSpecificInputImpl { + return BaseRecoveryPlanProviderSpecificInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanA2AInput{} + +func (s RecoveryPlanA2AInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanA2AInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanA2AInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanA2AInput: %+v", err) + } + + decoded["instanceType"] = "A2A" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanA2AInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanaction.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanaction.go new file mode 100644 index 00000000000..176b1d7a5f8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanaction.go @@ -0,0 +1,48 @@ +package replicationrecoveryplans + +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 RecoveryPlanAction struct { + ActionName string `json:"actionName"` + CustomDetails RecoveryPlanActionDetails `json:"customDetails"` + FailoverDirections []PossibleOperationsDirections `json:"failoverDirections"` + FailoverTypes []ReplicationProtectedItemOperation `json:"failoverTypes"` +} + +var _ json.Unmarshaler = &RecoveryPlanAction{} + +func (s *RecoveryPlanAction) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ActionName string `json:"actionName"` + FailoverDirections []PossibleOperationsDirections `json:"failoverDirections"` + FailoverTypes []ReplicationProtectedItemOperation `json:"failoverTypes"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ActionName = decoded.ActionName + s.FailoverDirections = decoded.FailoverDirections + s.FailoverTypes = decoded.FailoverTypes + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanAction into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["customDetails"]; ok { + impl, err := UnmarshalRecoveryPlanActionDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CustomDetails' for 'RecoveryPlanAction': %+v", err) + } + s.CustomDetails = impl + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanactiondetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanactiondetails.go new file mode 100644 index 00000000000..cd463d578aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanactiondetails.go @@ -0,0 +1,91 @@ +package replicationrecoveryplans + +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 RecoveryPlanActionDetails interface { + RecoveryPlanActionDetails() BaseRecoveryPlanActionDetailsImpl +} + +var _ RecoveryPlanActionDetails = BaseRecoveryPlanActionDetailsImpl{} + +type BaseRecoveryPlanActionDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseRecoveryPlanActionDetailsImpl) RecoveryPlanActionDetails() BaseRecoveryPlanActionDetailsImpl { + return s +} + +var _ RecoveryPlanActionDetails = RawRecoveryPlanActionDetailsImpl{} + +// RawRecoveryPlanActionDetailsImpl 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 RawRecoveryPlanActionDetailsImpl struct { + recoveryPlanActionDetails BaseRecoveryPlanActionDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryPlanActionDetailsImpl) RecoveryPlanActionDetails() BaseRecoveryPlanActionDetailsImpl { + return s.recoveryPlanActionDetails +} + +func UnmarshalRecoveryPlanActionDetailsImplementation(input []byte) (RecoveryPlanActionDetails, 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 RecoveryPlanActionDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AutomationRunbookActionDetails") { + var out RecoveryPlanAutomationRunbookActionDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanAutomationRunbookActionDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ManualActionDetails") { + var out RecoveryPlanManualActionDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanManualActionDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ScriptActionDetails") { + var out RecoveryPlanScriptActionDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanScriptActionDetails: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryPlanActionDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryPlanActionDetailsImpl: %+v", err) + } + + return RawRecoveryPlanActionDetailsImpl{ + recoveryPlanActionDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanautomationrunbookactiondetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanautomationrunbookactiondetails.go new file mode 100644 index 00000000000..a1648419ce9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanautomationrunbookactiondetails.go @@ -0,0 +1,52 @@ +package replicationrecoveryplans + +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 _ RecoveryPlanActionDetails = RecoveryPlanAutomationRunbookActionDetails{} + +type RecoveryPlanAutomationRunbookActionDetails struct { + FabricLocation RecoveryPlanActionLocation `json:"fabricLocation"` + RunbookId *string `json:"runbookId,omitempty"` + Timeout *string `json:"timeout,omitempty"` + + // Fields inherited from RecoveryPlanActionDetails + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanAutomationRunbookActionDetails) RecoveryPlanActionDetails() BaseRecoveryPlanActionDetailsImpl { + return BaseRecoveryPlanActionDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanAutomationRunbookActionDetails{} + +func (s RecoveryPlanAutomationRunbookActionDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanAutomationRunbookActionDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanAutomationRunbookActionDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanAutomationRunbookActionDetails: %+v", err) + } + + decoded["instanceType"] = "AutomationRunbookActionDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanAutomationRunbookActionDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplangroup.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplangroup.go new file mode 100644 index 00000000000..9100cabc9e0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplangroup.go @@ -0,0 +1,11 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanGroup struct { + EndGroupActions *[]RecoveryPlanAction `json:"endGroupActions,omitempty"` + GroupType RecoveryPlanGroupType `json:"groupType"` + ReplicationProtectedItems *[]RecoveryPlanProtectedItem `json:"replicationProtectedItems,omitempty"` + StartGroupActions *[]RecoveryPlanAction `json:"startGroupActions,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailbackinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailbackinput.go new file mode 100644 index 00000000000..9a4b0f1b42f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailbackinput.go @@ -0,0 +1,51 @@ +package replicationrecoveryplans + +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 _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanHyperVReplicaAzureFailbackInput{} + +type RecoveryPlanHyperVReplicaAzureFailbackInput struct { + DataSyncOption DataSyncStatus `json:"dataSyncOption"` + RecoveryVMCreationOption AlternateLocationRecoveryOption `json:"recoveryVmCreationOption"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanHyperVReplicaAzureFailbackInput) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return BaseRecoveryPlanProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanHyperVReplicaAzureFailbackInput{} + +func (s RecoveryPlanHyperVReplicaAzureFailbackInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanHyperVReplicaAzureFailbackInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanHyperVReplicaAzureFailbackInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanHyperVReplicaAzureFailbackInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzureFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanHyperVReplicaAzureFailbackInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailoverinput.go new file mode 100644 index 00000000000..34356511841 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanhypervreplicaazurefailoverinput.go @@ -0,0 +1,52 @@ +package replicationrecoveryplans + +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 _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanHyperVReplicaAzureFailoverInput{} + +type RecoveryPlanHyperVReplicaAzureFailoverInput struct { + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + RecoveryPointType *HyperVReplicaAzureRpRecoveryPointType `json:"recoveryPointType,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanHyperVReplicaAzureFailoverInput) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return BaseRecoveryPlanProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanHyperVReplicaAzureFailoverInput{} + +func (s RecoveryPlanHyperVReplicaAzureFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanHyperVReplicaAzureFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanHyperVReplicaAzureFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanHyperVReplicaAzureFailoverInput: %+v", err) + } + + decoded["instanceType"] = "HyperVReplicaAzure" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanHyperVReplicaAzureFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplaninmageazurev2failoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplaninmageazurev2failoverinput.go new file mode 100644 index 00000000000..3bdbbc0769f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplaninmageazurev2failoverinput.go @@ -0,0 +1,51 @@ +package replicationrecoveryplans + +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 _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanInMageAzureV2FailoverInput{} + +type RecoveryPlanInMageAzureV2FailoverInput struct { + RecoveryPointType InMageV2RpRecoveryPointType `json:"recoveryPointType"` + UseMultiVMSyncPoint *string `json:"useMultiVmSyncPoint,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanInMageAzureV2FailoverInput) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return BaseRecoveryPlanProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanInMageAzureV2FailoverInput{} + +func (s RecoveryPlanInMageAzureV2FailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanInMageAzureV2FailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanInMageAzureV2FailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanInMageAzureV2FailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMageAzureV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanInMageAzureV2FailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplaninmagefailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplaninmagefailoverinput.go new file mode 100644 index 00000000000..bb3d2294b2b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplaninmagefailoverinput.go @@ -0,0 +1,50 @@ +package replicationrecoveryplans + +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 _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanInMageFailoverInput{} + +type RecoveryPlanInMageFailoverInput struct { + RecoveryPointType RpInMageRecoveryPointType `json:"recoveryPointType"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanInMageFailoverInput) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return BaseRecoveryPlanProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanInMageFailoverInput{} + +func (s RecoveryPlanInMageFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanInMageFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanInMageFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanInMageFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanInMageFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplaninmagercmfailbackfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplaninmagercmfailbackfailoverinput.go new file mode 100644 index 00000000000..f49c9de401d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplaninmagercmfailbackfailoverinput.go @@ -0,0 +1,51 @@ +package replicationrecoveryplans + +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 _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanInMageRcmFailbackFailoverInput{} + +type RecoveryPlanInMageRcmFailbackFailoverInput struct { + RecoveryPointType InMageRcmFailbackRecoveryPointType `json:"recoveryPointType"` + UseMultiVMSyncPoint *string `json:"useMultiVmSyncPoint,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanInMageRcmFailbackFailoverInput) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return BaseRecoveryPlanProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanInMageRcmFailbackFailoverInput{} + +func (s RecoveryPlanInMageRcmFailbackFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanInMageRcmFailbackFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanInMageRcmFailbackFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanInMageRcmFailbackFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcmFailback" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanInMageRcmFailbackFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplaninmagercmfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplaninmagercmfailoverinput.go new file mode 100644 index 00000000000..04eb0d55758 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplaninmagercmfailoverinput.go @@ -0,0 +1,51 @@ +package replicationrecoveryplans + +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 _ RecoveryPlanProviderSpecificFailoverInput = RecoveryPlanInMageRcmFailoverInput{} + +type RecoveryPlanInMageRcmFailoverInput struct { + RecoveryPointType RecoveryPlanPointType `json:"recoveryPointType"` + UseMultiVMSyncPoint *string `json:"useMultiVmSyncPoint,omitempty"` + + // Fields inherited from RecoveryPlanProviderSpecificFailoverInput + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanInMageRcmFailoverInput) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return BaseRecoveryPlanProviderSpecificFailoverInputImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanInMageRcmFailoverInput{} + +func (s RecoveryPlanInMageRcmFailoverInput) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanInMageRcmFailoverInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanInMageRcmFailoverInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanInMageRcmFailoverInput: %+v", err) + } + + decoded["instanceType"] = "InMageRcm" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanInMageRcmFailoverInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanmanualactiondetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanmanualactiondetails.go new file mode 100644 index 00000000000..91503cc854c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanmanualactiondetails.go @@ -0,0 +1,50 @@ +package replicationrecoveryplans + +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 _ RecoveryPlanActionDetails = RecoveryPlanManualActionDetails{} + +type RecoveryPlanManualActionDetails struct { + Description *string `json:"description,omitempty"` + + // Fields inherited from RecoveryPlanActionDetails + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanManualActionDetails) RecoveryPlanActionDetails() BaseRecoveryPlanActionDetailsImpl { + return BaseRecoveryPlanActionDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanManualActionDetails{} + +func (s RecoveryPlanManualActionDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanManualActionDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanManualActionDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanManualActionDetails: %+v", err) + } + + decoded["instanceType"] = "ManualActionDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanManualActionDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinput.go new file mode 100644 index 00000000000..5afa04d9119 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanPlannedFailoverInput struct { + Properties RecoveryPlanPlannedFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinputproperties.go new file mode 100644 index 00000000000..81ea5a587bb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanplannedfailoverinputproperties.go @@ -0,0 +1,51 @@ +package replicationrecoveryplans + +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 RecoveryPlanPlannedFailoverInputProperties struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` +} + +var _ json.Unmarshaler = &RecoveryPlanPlannedFailoverInputProperties{} + +func (s *RecoveryPlanPlannedFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanPlannedFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificDetails into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificFailoverInput, 0) + for i, val := range listTemp { + impl, err := UnmarshalRecoveryPlanProviderSpecificFailoverInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificDetails' for 'RecoveryPlanPlannedFailoverInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificDetails = &output + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanproperties.go new file mode 100644 index 00000000000..035d56e1864 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanproperties.go @@ -0,0 +1,132 @@ +package replicationrecoveryplans + +import ( + "encoding/json" + "fmt" + "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 RecoveryPlanProperties struct { + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + CurrentScenarioStatus *string `json:"currentScenarioStatus,omitempty"` + CurrentScenarioStatusDescription *string `json:"currentScenarioStatusDescription,omitempty"` + FailoverDeploymentModel *string `json:"failoverDeploymentModel,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Groups *[]RecoveryPlanGroup `json:"groups,omitempty"` + LastPlannedFailoverTime *string `json:"lastPlannedFailoverTime,omitempty"` + LastTestFailoverTime *string `json:"lastTestFailoverTime,omitempty"` + LastUnplannedFailoverTime *string `json:"lastUnplannedFailoverTime,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryFabricId *string `json:"primaryFabricId,omitempty"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificDetails `json:"providerSpecificDetails,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricId *string `json:"recoveryFabricId,omitempty"` + ReplicationProviders *[]string `json:"replicationProviders,omitempty"` +} + +func (o *RecoveryPlanProperties) GetLastPlannedFailoverTimeAsTime() (*time.Time, error) { + if o.LastPlannedFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastPlannedFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPlanProperties) SetLastPlannedFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastPlannedFailoverTime = &formatted +} + +func (o *RecoveryPlanProperties) GetLastTestFailoverTimeAsTime() (*time.Time, error) { + if o.LastTestFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastTestFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPlanProperties) SetLastTestFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastTestFailoverTime = &formatted +} + +func (o *RecoveryPlanProperties) GetLastUnplannedFailoverTimeAsTime() (*time.Time, error) { + if o.LastUnplannedFailoverTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUnplannedFailoverTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPlanProperties) SetLastUnplannedFailoverTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUnplannedFailoverTime = &formatted +} + +var _ json.Unmarshaler = &RecoveryPlanProperties{} + +func (s *RecoveryPlanProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + CurrentScenarioStatus *string `json:"currentScenarioStatus,omitempty"` + CurrentScenarioStatusDescription *string `json:"currentScenarioStatusDescription,omitempty"` + FailoverDeploymentModel *string `json:"failoverDeploymentModel,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Groups *[]RecoveryPlanGroup `json:"groups,omitempty"` + LastPlannedFailoverTime *string `json:"lastPlannedFailoverTime,omitempty"` + LastTestFailoverTime *string `json:"lastTestFailoverTime,omitempty"` + LastUnplannedFailoverTime *string `json:"lastUnplannedFailoverTime,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + PrimaryFabricId *string `json:"primaryFabricId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricId *string `json:"recoveryFabricId,omitempty"` + ReplicationProviders *[]string `json:"replicationProviders,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AllowedOperations = decoded.AllowedOperations + s.CurrentScenario = decoded.CurrentScenario + s.CurrentScenarioStatus = decoded.CurrentScenarioStatus + s.CurrentScenarioStatusDescription = decoded.CurrentScenarioStatusDescription + s.FailoverDeploymentModel = decoded.FailoverDeploymentModel + s.FriendlyName = decoded.FriendlyName + s.Groups = decoded.Groups + s.LastPlannedFailoverTime = decoded.LastPlannedFailoverTime + s.LastTestFailoverTime = decoded.LastTestFailoverTime + s.LastUnplannedFailoverTime = decoded.LastUnplannedFailoverTime + s.PrimaryFabricFriendlyName = decoded.PrimaryFabricFriendlyName + s.PrimaryFabricId = decoded.PrimaryFabricId + s.RecoveryFabricFriendlyName = decoded.RecoveryFabricFriendlyName + s.RecoveryFabricId = decoded.RecoveryFabricId + s.ReplicationProviders = decoded.ReplicationProviders + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificDetails into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificDetails, 0) + for i, val := range listTemp { + impl, err := UnmarshalRecoveryPlanProviderSpecificDetailsImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificDetails' for 'RecoveryPlanProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificDetails = &output + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanprotecteditem.go new file mode 100644 index 00000000000..e3d9c1e2cbf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanprotecteditem.go @@ -0,0 +1,9 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanProtectedItem struct { + Id *string `json:"id,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanproviderspecificdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanproviderspecificdetails.go new file mode 100644 index 00000000000..903584989ae --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanproviderspecificdetails.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +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 RecoveryPlanProviderSpecificDetails interface { + RecoveryPlanProviderSpecificDetails() BaseRecoveryPlanProviderSpecificDetailsImpl +} + +var _ RecoveryPlanProviderSpecificDetails = BaseRecoveryPlanProviderSpecificDetailsImpl{} + +type BaseRecoveryPlanProviderSpecificDetailsImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseRecoveryPlanProviderSpecificDetailsImpl) RecoveryPlanProviderSpecificDetails() BaseRecoveryPlanProviderSpecificDetailsImpl { + return s +} + +var _ RecoveryPlanProviderSpecificDetails = RawRecoveryPlanProviderSpecificDetailsImpl{} + +// RawRecoveryPlanProviderSpecificDetailsImpl 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 RawRecoveryPlanProviderSpecificDetailsImpl struct { + recoveryPlanProviderSpecificDetails BaseRecoveryPlanProviderSpecificDetailsImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryPlanProviderSpecificDetailsImpl) RecoveryPlanProviderSpecificDetails() BaseRecoveryPlanProviderSpecificDetailsImpl { + return s.recoveryPlanProviderSpecificDetails +} + +func UnmarshalRecoveryPlanProviderSpecificDetailsImplementation(input []byte) (RecoveryPlanProviderSpecificDetails, 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 RecoveryPlanProviderSpecificDetails into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out RecoveryPlanA2ADetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanA2ADetails: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryPlanProviderSpecificDetailsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryPlanProviderSpecificDetailsImpl: %+v", err) + } + + return RawRecoveryPlanProviderSpecificDetailsImpl{ + recoveryPlanProviderSpecificDetails: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanproviderspecificfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanproviderspecificfailoverinput.go new file mode 100644 index 00000000000..d5045326bfc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanproviderspecificfailoverinput.go @@ -0,0 +1,123 @@ +package replicationrecoveryplans + +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 RecoveryPlanProviderSpecificFailoverInput interface { + RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl +} + +var _ RecoveryPlanProviderSpecificFailoverInput = BaseRecoveryPlanProviderSpecificFailoverInputImpl{} + +type BaseRecoveryPlanProviderSpecificFailoverInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseRecoveryPlanProviderSpecificFailoverInputImpl) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return s +} + +var _ RecoveryPlanProviderSpecificFailoverInput = RawRecoveryPlanProviderSpecificFailoverInputImpl{} + +// RawRecoveryPlanProviderSpecificFailoverInputImpl 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 RawRecoveryPlanProviderSpecificFailoverInputImpl struct { + recoveryPlanProviderSpecificFailoverInput BaseRecoveryPlanProviderSpecificFailoverInputImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryPlanProviderSpecificFailoverInputImpl) RecoveryPlanProviderSpecificFailoverInput() BaseRecoveryPlanProviderSpecificFailoverInputImpl { + return s.recoveryPlanProviderSpecificFailoverInput +} + +func UnmarshalRecoveryPlanProviderSpecificFailoverInputImplementation(input []byte) (RecoveryPlanProviderSpecificFailoverInput, 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 RecoveryPlanProviderSpecificFailoverInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out RecoveryPlanA2AFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanA2AFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzureFailback") { + var out RecoveryPlanHyperVReplicaAzureFailbackInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanHyperVReplicaAzureFailbackInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HyperVReplicaAzure") { + var out RecoveryPlanHyperVReplicaAzureFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanHyperVReplicaAzureFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageAzureV2") { + var out RecoveryPlanInMageAzureV2FailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanInMageAzureV2FailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMage") { + var out RecoveryPlanInMageFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanInMageFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcmFailback") { + var out RecoveryPlanInMageRcmFailbackFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanInMageRcmFailbackFailoverInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InMageRcm") { + var out RecoveryPlanInMageRcmFailoverInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanInMageRcmFailoverInput: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryPlanProviderSpecificFailoverInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryPlanProviderSpecificFailoverInputImpl: %+v", err) + } + + return RawRecoveryPlanProviderSpecificFailoverInputImpl{ + recoveryPlanProviderSpecificFailoverInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanproviderspecificinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanproviderspecificinput.go new file mode 100644 index 00000000000..8b431bd3c1b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanproviderspecificinput.go @@ -0,0 +1,75 @@ +package replicationrecoveryplans + +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 RecoveryPlanProviderSpecificInput interface { + RecoveryPlanProviderSpecificInput() BaseRecoveryPlanProviderSpecificInputImpl +} + +var _ RecoveryPlanProviderSpecificInput = BaseRecoveryPlanProviderSpecificInputImpl{} + +type BaseRecoveryPlanProviderSpecificInputImpl struct { + InstanceType string `json:"instanceType"` +} + +func (s BaseRecoveryPlanProviderSpecificInputImpl) RecoveryPlanProviderSpecificInput() BaseRecoveryPlanProviderSpecificInputImpl { + return s +} + +var _ RecoveryPlanProviderSpecificInput = RawRecoveryPlanProviderSpecificInputImpl{} + +// RawRecoveryPlanProviderSpecificInputImpl 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 RawRecoveryPlanProviderSpecificInputImpl struct { + recoveryPlanProviderSpecificInput BaseRecoveryPlanProviderSpecificInputImpl + Type string + Values map[string]interface{} +} + +func (s RawRecoveryPlanProviderSpecificInputImpl) RecoveryPlanProviderSpecificInput() BaseRecoveryPlanProviderSpecificInputImpl { + return s.recoveryPlanProviderSpecificInput +} + +func UnmarshalRecoveryPlanProviderSpecificInputImplementation(input []byte) (RecoveryPlanProviderSpecificInput, 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 RecoveryPlanProviderSpecificInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["instanceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "A2A") { + var out RecoveryPlanA2AInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecoveryPlanA2AInput: %+v", err) + } + return out, nil + } + + var parent BaseRecoveryPlanProviderSpecificInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseRecoveryPlanProviderSpecificInputImpl: %+v", err) + } + + return RawRecoveryPlanProviderSpecificInputImpl{ + recoveryPlanProviderSpecificInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanscriptactiondetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanscriptactiondetails.go new file mode 100644 index 00000000000..9e44da053e9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanscriptactiondetails.go @@ -0,0 +1,52 @@ +package replicationrecoveryplans + +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 _ RecoveryPlanActionDetails = RecoveryPlanScriptActionDetails{} + +type RecoveryPlanScriptActionDetails struct { + FabricLocation RecoveryPlanActionLocation `json:"fabricLocation"` + Path string `json:"path"` + Timeout *string `json:"timeout,omitempty"` + + // Fields inherited from RecoveryPlanActionDetails + + InstanceType string `json:"instanceType"` +} + +func (s RecoveryPlanScriptActionDetails) RecoveryPlanActionDetails() BaseRecoveryPlanActionDetailsImpl { + return BaseRecoveryPlanActionDetailsImpl{ + InstanceType: s.InstanceType, + } +} + +var _ json.Marshaler = RecoveryPlanScriptActionDetails{} + +func (s RecoveryPlanScriptActionDetails) MarshalJSON() ([]byte, error) { + type wrapper RecoveryPlanScriptActionDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecoveryPlanScriptActionDetails: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPlanScriptActionDetails: %+v", err) + } + + decoded["instanceType"] = "ScriptActionDetails" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecoveryPlanScriptActionDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinput.go new file mode 100644 index 00000000000..4379adce6cd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanTestFailoverCleanupInput struct { + Properties RecoveryPlanTestFailoverCleanupInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinputproperties.go new file mode 100644 index 00000000000..2b3b65c28c3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplantestfailovercleanupinputproperties.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanTestFailoverCleanupInputProperties struct { + Comments *string `json:"comments,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplantestfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplantestfailoverinput.go new file mode 100644 index 00000000000..c5706924b4e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplantestfailoverinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanTestFailoverInput struct { + Properties RecoveryPlanTestFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplantestfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplantestfailoverinputproperties.go new file mode 100644 index 00000000000..71fc1444108 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplantestfailoverinputproperties.go @@ -0,0 +1,57 @@ +package replicationrecoveryplans + +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 RecoveryPlanTestFailoverInputProperties struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + NetworkId *string `json:"networkId,omitempty"` + NetworkType string `json:"networkType"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` +} + +var _ json.Unmarshaler = &RecoveryPlanTestFailoverInputProperties{} + +func (s *RecoveryPlanTestFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + NetworkId *string `json:"networkId,omitempty"` + NetworkType string `json:"networkType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.NetworkId = decoded.NetworkId + s.NetworkType = decoded.NetworkType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanTestFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificDetails into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificFailoverInput, 0) + for i, val := range listTemp { + impl, err := UnmarshalRecoveryPlanProviderSpecificFailoverInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificDetails' for 'RecoveryPlanTestFailoverInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificDetails = &output + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinput.go new file mode 100644 index 00000000000..92fc6578c58 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanUnplannedFailoverInput struct { + Properties RecoveryPlanUnplannedFailoverInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinputproperties.go new file mode 100644 index 00000000000..e5c8bdd52c9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_recoveryplanunplannedfailoverinputproperties.go @@ -0,0 +1,54 @@ +package replicationrecoveryplans + +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 RecoveryPlanUnplannedFailoverInputProperties struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` + SourceSiteOperations SourceSiteOperations `json:"sourceSiteOperations"` +} + +var _ json.Unmarshaler = &RecoveryPlanUnplannedFailoverInputProperties{} + +func (s *RecoveryPlanUnplannedFailoverInputProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection"` + SourceSiteOperations SourceSiteOperations `json:"sourceSiteOperations"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FailoverDirection = decoded.FailoverDirection + s.SourceSiteOperations = decoded.SourceSiteOperations + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPlanUnplannedFailoverInputProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["providerSpecificDetails"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProviderSpecificDetails into list []json.RawMessage: %+v", err) + } + + output := make([]RecoveryPlanProviderSpecificFailoverInput, 0) + for i, val := range listTemp { + impl, err := UnmarshalRecoveryPlanProviderSpecificFailoverInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProviderSpecificDetails' for 'RecoveryPlanUnplannedFailoverInputProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ProviderSpecificDetails = &output + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_updaterecoveryplaninput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_updaterecoveryplaninput.go new file mode 100644 index 00000000000..f1611672eed --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_updaterecoveryplaninput.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateRecoveryPlanInput struct { + Properties *UpdateRecoveryPlanInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_updaterecoveryplaninputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_updaterecoveryplaninputproperties.go new file mode 100644 index 00000000000..dba269e1ee5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/model_updaterecoveryplaninputproperties.go @@ -0,0 +1,8 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateRecoveryPlanInputProperties struct { + Groups *[]RecoveryPlanGroup `json:"groups,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/predicates.go new file mode 100644 index 00000000000..d6c5e9c2534 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/predicates.go @@ -0,0 +1,32 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPlanOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RecoveryPlanOperationPredicate) Matches(input RecoveryPlan) 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/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/version.go new file mode 100644 index 00000000000..9b2dfaa9f13 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryplans/version.go @@ -0,0 +1,10 @@ +package replicationrecoveryplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationrecoveryplans/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/README.md new file mode 100644 index 00000000000..d723e236b2f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/README.md @@ -0,0 +1,123 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders` Documentation + +The `replicationrecoveryservicesproviders` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders" +``` + + +### Client Initialization + +```go +client := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProvidersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.Create` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationRecoveryServicesProviderName") + +payload := replicationrecoveryservicesproviders.AddRecoveryServicesProviderInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.Delete` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationRecoveryServicesProviderName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.Get` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationRecoveryServicesProviderName") + +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: `ReplicationRecoveryServicesProvidersClient.List` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// 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: `ReplicationRecoveryServicesProvidersClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.Purge` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationRecoveryServicesProviderName") + +if err := client.PurgeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationRecoveryServicesProvidersClient.RefreshProvider` + +```go +ctx := context.TODO() +id := replicationrecoveryservicesproviders.NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationRecoveryServicesProviderName") + +if err := client.RefreshProviderThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/client.go new file mode 100644 index 00000000000..a6150690dac --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/client.go @@ -0,0 +1,26 @@ +package replicationrecoveryservicesproviders + +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 ReplicationRecoveryServicesProvidersClient struct { + Client *resourcemanager.Client +} + +func NewReplicationRecoveryServicesProvidersClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationRecoveryServicesProvidersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationrecoveryservicesproviders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationRecoveryServicesProvidersClient: %+v", err) + } + + return &ReplicationRecoveryServicesProvidersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/constants.go new file mode 100644 index 00000000000..1019dcf0757 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/constants.go @@ -0,0 +1,101 @@ +package replicationrecoveryservicesproviders + +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 AgentVersionStatus string + +const ( + AgentVersionStatusDeprecated AgentVersionStatus = "Deprecated" + AgentVersionStatusNotSupported AgentVersionStatus = "NotSupported" + AgentVersionStatusSecurityUpdateRequired AgentVersionStatus = "SecurityUpdateRequired" + AgentVersionStatusSupported AgentVersionStatus = "Supported" + AgentVersionStatusUpdateRequired AgentVersionStatus = "UpdateRequired" +) + +func PossibleValuesForAgentVersionStatus() []string { + return []string{ + string(AgentVersionStatusDeprecated), + string(AgentVersionStatusNotSupported), + string(AgentVersionStatusSecurityUpdateRequired), + string(AgentVersionStatusSupported), + string(AgentVersionStatusUpdateRequired), + } +} + +func (s *AgentVersionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentVersionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentVersionStatus(input string) (*AgentVersionStatus, error) { + vals := map[string]AgentVersionStatus{ + "deprecated": AgentVersionStatusDeprecated, + "notsupported": AgentVersionStatusNotSupported, + "securityupdaterequired": AgentVersionStatusSecurityUpdateRequired, + "supported": AgentVersionStatusSupported, + "updaterequired": AgentVersionStatusUpdateRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentVersionStatus(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_replicationfabric.go new file mode 100644 index 00000000000..9b5124c9f9f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_replicationfabric.go @@ -0,0 +1,139 @@ +package replicationrecoveryservicesproviders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationFabricId{}) +} + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_replicationfabric_test.go new file mode 100644 index 00000000000..d7afe711ff4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationrecoveryservicesproviders + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider.go new file mode 100644 index 00000000000..9cba3d8c658 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider.go @@ -0,0 +1,148 @@ +package replicationrecoveryservicesproviders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationRecoveryServicesProviderId{}) +} + +var _ resourceids.ResourceId = &ReplicationRecoveryServicesProviderId{} + +// ReplicationRecoveryServicesProviderId is a struct representing the Resource ID for a Replication Recovery Services Provider +type ReplicationRecoveryServicesProviderId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationRecoveryServicesProviderName string +} + +// NewReplicationRecoveryServicesProviderID returns a new ReplicationRecoveryServicesProviderId struct +func NewReplicationRecoveryServicesProviderID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationRecoveryServicesProviderName string) ReplicationRecoveryServicesProviderId { + return ReplicationRecoveryServicesProviderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationRecoveryServicesProviderName: replicationRecoveryServicesProviderName, + } +} + +// ParseReplicationRecoveryServicesProviderID parses 'input' into a ReplicationRecoveryServicesProviderId +func ParseReplicationRecoveryServicesProviderID(input string) (*ReplicationRecoveryServicesProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationRecoveryServicesProviderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationRecoveryServicesProviderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationRecoveryServicesProviderIDInsensitively parses 'input' case-insensitively into a ReplicationRecoveryServicesProviderId +// note: this method should only be used for API response data and not user input +func ParseReplicationRecoveryServicesProviderIDInsensitively(input string) (*ReplicationRecoveryServicesProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationRecoveryServicesProviderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationRecoveryServicesProviderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationRecoveryServicesProviderId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationRecoveryServicesProviderName, ok = input.Parsed["replicationRecoveryServicesProviderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationRecoveryServicesProviderName", input) + } + + return nil +} + +// ValidateReplicationRecoveryServicesProviderID checks that 'input' can be parsed as a Replication Recovery Services Provider ID +func ValidateReplicationRecoveryServicesProviderID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationRecoveryServicesProviderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Recovery Services Provider ID +func (id ReplicationRecoveryServicesProviderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationRecoveryServicesProviders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationRecoveryServicesProviderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Recovery Services Provider ID +func (id ReplicationRecoveryServicesProviderId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationRecoveryServicesProviders", "replicationRecoveryServicesProviders", "replicationRecoveryServicesProviders"), + resourceids.UserSpecifiedSegment("replicationRecoveryServicesProviderName", "replicationRecoveryServicesProviderName"), + } +} + +// String returns a human-readable description of this Replication Recovery Services Provider ID +func (id ReplicationRecoveryServicesProviderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Recovery Services Provider Name: %q", id.ReplicationRecoveryServicesProviderName), + } + return fmt.Sprintf("Replication Recovery Services Provider (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider_test.go new file mode 100644 index 00000000000..330064d9655 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_replicationrecoveryservicesprovider_test.go @@ -0,0 +1,372 @@ +package replicationrecoveryservicesproviders + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationRecoveryServicesProviderId{} + +func TestNewReplicationRecoveryServicesProviderID(t *testing.T) { + id := NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationRecoveryServicesProviderName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationRecoveryServicesProviderName != "replicationRecoveryServicesProviderName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationRecoveryServicesProviderName'", id.ReplicationRecoveryServicesProviderName, "replicationRecoveryServicesProviderName") + } +} + +func TestFormatReplicationRecoveryServicesProviderID(t *testing.T) { + actual := NewReplicationRecoveryServicesProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationRecoveryServicesProviderName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationRecoveryServicesProviderID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationRecoveryServicesProviderId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationRecoveryServicesProviders", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderName", + Expected: &ReplicationRecoveryServicesProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationRecoveryServicesProviderName: "replicationRecoveryServicesProviderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationRecoveryServicesProviderID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationRecoveryServicesProviderName != v.Expected.ReplicationRecoveryServicesProviderName { + t.Fatalf("Expected %q but got %q for ReplicationRecoveryServicesProviderName", v.Expected.ReplicationRecoveryServicesProviderName, actual.ReplicationRecoveryServicesProviderName) + } + + } +} + +func TestParseReplicationRecoveryServicesProviderIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationRecoveryServicesProviderId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationRecoveryServicesProviders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderName", + Expected: &ReplicationRecoveryServicesProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationRecoveryServicesProviderName: "replicationRecoveryServicesProviderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationRecoveryServicesProviders/replicationRecoveryServicesProviderName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErS/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErNaMe", + Expected: &ReplicationRecoveryServicesProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationRecoveryServicesProviderName: "rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErS/rEpLiCaTiOnReCoVeRySeRvIcEsPrOvIdErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationRecoveryServicesProviderIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationRecoveryServicesProviderName != v.Expected.ReplicationRecoveryServicesProviderName { + t.Fatalf("Expected %q but got %q for ReplicationRecoveryServicesProviderName", v.Expected.ReplicationRecoveryServicesProviderName, actual.ReplicationRecoveryServicesProviderName) + } + + } +} + +func TestSegmentsForReplicationRecoveryServicesProviderId(t *testing.T) { + segments := ReplicationRecoveryServicesProviderId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationRecoveryServicesProviderId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_vault.go new file mode 100644 index 00000000000..e0624e18242 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_vault.go @@ -0,0 +1,130 @@ +package replicationrecoveryservicesproviders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_vault_test.go new file mode 100644 index 00000000000..bd041b99e7c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationrecoveryservicesproviders + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_create.go new file mode 100644 index 00000000000..d703662cb7a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_create.go @@ -0,0 +1,75 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *RecoveryServicesProvider +} + +// Create ... +func (c ReplicationRecoveryServicesProvidersClient) Create(ctx context.Context, id ReplicationRecoveryServicesProviderId, input AddRecoveryServicesProviderInput) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationRecoveryServicesProvidersClient) CreateThenPoll(ctx context.Context, id ReplicationRecoveryServicesProviderId, input AddRecoveryServicesProviderInput) 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/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_delete.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_delete.go new file mode 100644 index 00000000000..d415ca70852 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_delete.go @@ -0,0 +1,70 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 ReplicationRecoveryServicesProvidersClient) Delete(ctx context.Context, id ReplicationRecoveryServicesProviderId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/remove", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.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 ReplicationRecoveryServicesProvidersClient) DeleteThenPoll(ctx context.Context, id ReplicationRecoveryServicesProviderId) 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/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_get.go new file mode 100644 index 00000000000..608e93729f9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_get.go @@ -0,0 +1,53 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *RecoveryServicesProvider +} + +// Get ... +func (c ReplicationRecoveryServicesProvidersClient) Get(ctx context.Context, id ReplicationRecoveryServicesProviderId) (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 RecoveryServicesProvider + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_list.go new file mode 100644 index 00000000000..9f87fd102aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_list.go @@ -0,0 +1,105 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]RecoveryServicesProvider +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RecoveryServicesProvider +} + +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 ReplicationRecoveryServicesProvidersClient) List(ctx context.Context, id VaultId) (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/replicationRecoveryServicesProviders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RecoveryServicesProvider `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 ReplicationRecoveryServicesProvidersClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RecoveryServicesProviderOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationRecoveryServicesProvidersClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate RecoveryServicesProviderOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RecoveryServicesProvider, 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/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..2acfd3b73c2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_listbyreplicationfabrics.go @@ -0,0 +1,105 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RecoveryServicesProvider +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []RecoveryServicesProvider +} + +type ListByReplicationFabricsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationFabricsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationFabrics ... +func (c ReplicationRecoveryServicesProvidersClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationFabricsCustomPager{}, + Path: fmt.Sprintf("%s/replicationRecoveryServicesProviders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RecoveryServicesProvider `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, RecoveryServicesProviderOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate RecoveryServicesProviderOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]RecoveryServicesProvider, 0) + + resp, err := c.ListByReplicationFabrics(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 = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_purge.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_purge.go new file mode 100644 index 00000000000..769e022934f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_purge.go @@ -0,0 +1,70 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c ReplicationRecoveryServicesProvidersClient) Purge(ctx context.Context, id ReplicationRecoveryServicesProviderId) (result PurgeOperationResponse, 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 +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c ReplicationRecoveryServicesProvidersClient) PurgeThenPoll(ctx context.Context, id ReplicationRecoveryServicesProviderId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_refreshprovider.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_refreshprovider.go new file mode 100644 index 00000000000..ccbc812c22a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/method_refreshprovider.go @@ -0,0 +1,71 @@ +package replicationrecoveryservicesproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RefreshProviderOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RecoveryServicesProvider +} + +// RefreshProvider ... +func (c ReplicationRecoveryServicesProvidersClient) RefreshProvider(ctx context.Context, id ReplicationRecoveryServicesProviderId) (result RefreshProviderOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/refreshProvider", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RefreshProviderThenPoll performs RefreshProvider then polls until it's completed +func (c ReplicationRecoveryServicesProvidersClient) RefreshProviderThenPoll(ctx context.Context, id ReplicationRecoveryServicesProviderId) error { + result, err := c.RefreshProvider(ctx, id) + if err != nil { + return fmt.Errorf("performing RefreshProvider: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RefreshProvider: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinput.go new file mode 100644 index 00000000000..2c945e24875 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinput.go @@ -0,0 +1,8 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddRecoveryServicesProviderInput struct { + Properties AddRecoveryServicesProviderInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinputproperties.go new file mode 100644 index 00000000000..9562bac2653 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_addrecoveryservicesproviderinputproperties.go @@ -0,0 +1,13 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddRecoveryServicesProviderInputProperties struct { + AuthenticationIdentityInput IdentityProviderInput `json:"authenticationIdentityInput"` + BiosId *string `json:"biosId,omitempty"` + DataPlaneAuthenticationIdentityInput *IdentityProviderInput `json:"dataPlaneAuthenticationIdentityInput,omitempty"` + MachineId *string `json:"machineId,omitempty"` + MachineName string `json:"machineName"` + ResourceAccessIdentityInput IdentityProviderInput `json:"resourceAccessIdentityInput"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_healtherror.go new file mode 100644 index 00000000000..b0c92df9ee5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationrecoveryservicesproviders + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_identityproviderdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_identityproviderdetails.go new file mode 100644 index 00000000000..ab5ea5efed4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_identityproviderdetails.go @@ -0,0 +1,12 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviderDetails struct { + AadAuthority *string `json:"aadAuthority,omitempty"` + ApplicationId *string `json:"applicationId,omitempty"` + Audience *string `json:"audience,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_identityproviderinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_identityproviderinput.go new file mode 100644 index 00000000000..df9e5c5085d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_identityproviderinput.go @@ -0,0 +1,12 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviderInput struct { + AadAuthority string `json:"aadAuthority"` + ApplicationId string `json:"applicationId"` + Audience string `json:"audience"` + ObjectId string `json:"objectId"` + TenantId string `json:"tenantId"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_innerhealtherror.go new file mode 100644 index 00000000000..3ef08acf21c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationrecoveryservicesproviders + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_recoveryservicesprovider.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_recoveryservicesprovider.go new file mode 100644 index 00000000000..8b870a59529 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_recoveryservicesprovider.go @@ -0,0 +1,12 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryServicesProvider struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecoveryServicesProviderProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_recoveryservicesproviderproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_recoveryservicesproviderproperties.go new file mode 100644 index 00000000000..db54434b901 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_recoveryservicesproviderproperties.go @@ -0,0 +1,57 @@ +package replicationrecoveryservicesproviders + +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 RecoveryServicesProviderProperties struct { + AllowedScenarios *[]string `json:"allowedScenarios,omitempty"` + AuthenticationIdentityDetails *IdentityProviderDetails `json:"authenticationIdentityDetails,omitempty"` + BiosId *string `json:"biosId,omitempty"` + ConnectionStatus *string `json:"connectionStatus,omitempty"` + DataPlaneAuthenticationIdentityDetails *IdentityProviderDetails `json:"dataPlaneAuthenticationIdentityDetails,omitempty"` + DraIdentifier *string `json:"draIdentifier,omitempty"` + FabricFriendlyName *string `json:"fabricFriendlyName,omitempty"` + FabricType *string `json:"fabricType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + LastHeartBeat *string `json:"lastHeartBeat,omitempty"` + MachineId *string `json:"machineId,omitempty"` + MachineName *string `json:"machineName,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ProviderVersion *string `json:"providerVersion,omitempty"` + ProviderVersionDetails *VersionDetails `json:"providerVersionDetails,omitempty"` + ProviderVersionExpiryDate *string `json:"providerVersionExpiryDate,omitempty"` + ProviderVersionState *string `json:"providerVersionState,omitempty"` + ResourceAccessIdentityDetails *IdentityProviderDetails `json:"resourceAccessIdentityDetails,omitempty"` + ServerVersion *string `json:"serverVersion,omitempty"` +} + +func (o *RecoveryServicesProviderProperties) GetLastHeartBeatAsTime() (*time.Time, error) { + if o.LastHeartBeat == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartBeat, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryServicesProviderProperties) SetLastHeartBeatAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartBeat = &formatted +} + +func (o *RecoveryServicesProviderProperties) GetProviderVersionExpiryDateAsTime() (*time.Time, error) { + if o.ProviderVersionExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ProviderVersionExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryServicesProviderProperties) SetProviderVersionExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ProviderVersionExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_versiondetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_versiondetails.go new file mode 100644 index 00000000000..9a441abb5ca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/model_versiondetails.go @@ -0,0 +1,28 @@ +package replicationrecoveryservicesproviders + +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 VersionDetails struct { + ExpiryDate *string `json:"expiryDate,omitempty"` + Status *AgentVersionStatus `json:"status,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *VersionDetails) GetExpiryDateAsTime() (*time.Time, error) { + if o.ExpiryDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *VersionDetails) SetExpiryDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryDate = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/predicates.go new file mode 100644 index 00000000000..4377b19a42f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/predicates.go @@ -0,0 +1,32 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryServicesProviderOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RecoveryServicesProviderOperationPredicate) Matches(input RecoveryServicesProvider) 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/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/version.go new file mode 100644 index 00000000000..37a3b87503f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationrecoveryservicesproviders/version.go @@ -0,0 +1,10 @@ +package replicationrecoveryservicesproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationrecoveryservicesproviders/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/README.md new file mode 100644 index 00000000000..3e447302fa6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings` Documentation + +The `replicationstorageclassificationmappings` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings" +``` + + +### Client Initialization + +```go +client := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationStorageClassificationMappingsClient.Create` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName", "replicationStorageClassificationMappingName") + +payload := replicationstorageclassificationmappings.StorageClassificationMappingInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationStorageClassificationMappingsClient.Delete` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName", "replicationStorageClassificationMappingName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationStorageClassificationMappingsClient.Get` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName", "replicationStorageClassificationMappingName") + +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: `ReplicationStorageClassificationMappingsClient.List` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// 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: `ReplicationStorageClassificationMappingsClient.ListByReplicationStorageClassifications` + +```go +ctx := context.TODO() +id := replicationstorageclassificationmappings.NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName") + +// alternatively `client.ListByReplicationStorageClassifications(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationStorageClassificationsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/client.go new file mode 100644 index 00000000000..a92438ccd25 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/client.go @@ -0,0 +1,26 @@ +package replicationstorageclassificationmappings + +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 ReplicationStorageClassificationMappingsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationStorageClassificationMappingsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationStorageClassificationMappingsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationstorageclassificationmappings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationStorageClassificationMappingsClient: %+v", err) + } + + return &ReplicationStorageClassificationMappingsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_replicationstorageclassification.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_replicationstorageclassification.go new file mode 100644 index 00000000000..6153e2573af --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_replicationstorageclassification.go @@ -0,0 +1,148 @@ +package replicationstorageclassificationmappings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationStorageClassificationId{}) +} + +var _ resourceids.ResourceId = &ReplicationStorageClassificationId{} + +// ReplicationStorageClassificationId is a struct representing the Resource ID for a Replication Storage Classification +type ReplicationStorageClassificationId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationStorageClassificationName string +} + +// NewReplicationStorageClassificationID returns a new ReplicationStorageClassificationId struct +func NewReplicationStorageClassificationID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationStorageClassificationName string) ReplicationStorageClassificationId { + return ReplicationStorageClassificationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationStorageClassificationName: replicationStorageClassificationName, + } +} + +// ParseReplicationStorageClassificationID parses 'input' into a ReplicationStorageClassificationId +func ParseReplicationStorageClassificationID(input string) (*ReplicationStorageClassificationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationStorageClassificationIDInsensitively parses 'input' case-insensitively into a ReplicationStorageClassificationId +// note: this method should only be used for API response data and not user input +func ParseReplicationStorageClassificationIDInsensitively(input string) (*ReplicationStorageClassificationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationStorageClassificationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationStorageClassificationName, ok = input.Parsed["replicationStorageClassificationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationStorageClassificationName", input) + } + + return nil +} + +// ValidateReplicationStorageClassificationID checks that 'input' can be parsed as a Replication Storage Classification ID +func ValidateReplicationStorageClassificationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationStorageClassificationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Storage Classification ID +func (id ReplicationStorageClassificationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationStorageClassifications/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationStorageClassificationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Storage Classification ID +func (id ReplicationStorageClassificationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationStorageClassifications", "replicationStorageClassifications", "replicationStorageClassifications"), + resourceids.UserSpecifiedSegment("replicationStorageClassificationName", "replicationStorageClassificationName"), + } +} + +// String returns a human-readable description of this Replication Storage Classification ID +func (id ReplicationStorageClassificationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Storage Classification Name: %q", id.ReplicationStorageClassificationName), + } + return fmt.Sprintf("Replication Storage Classification (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_replicationstorageclassification_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_replicationstorageclassification_test.go new file mode 100644 index 00000000000..93419cf7b07 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_replicationstorageclassification_test.go @@ -0,0 +1,372 @@ +package replicationstorageclassificationmappings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationStorageClassificationId{} + +func TestNewReplicationStorageClassificationID(t *testing.T) { + id := NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationStorageClassificationName != "replicationStorageClassificationName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationStorageClassificationName'", id.ReplicationStorageClassificationName, "replicationStorageClassificationName") + } +} + +func TestFormatReplicationStorageClassificationID(t *testing.T) { + actual := NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationStorageClassificationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationStorageClassificationName: "replicationStorageClassificationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + } +} + +func TestParseReplicationStorageClassificationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationStorageClassificationName: "replicationStorageClassificationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationStorageClassificationName: "rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + } +} + +func TestSegmentsForReplicationStorageClassificationId(t *testing.T) { + segments := ReplicationStorageClassificationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationStorageClassificationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping.go new file mode 100644 index 00000000000..35968166e9f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping.go @@ -0,0 +1,157 @@ +package replicationstorageclassificationmappings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationStorageClassificationMappingId{}) +} + +var _ resourceids.ResourceId = &ReplicationStorageClassificationMappingId{} + +// ReplicationStorageClassificationMappingId is a struct representing the Resource ID for a Replication Storage Classification Mapping +type ReplicationStorageClassificationMappingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationStorageClassificationName string + ReplicationStorageClassificationMappingName string +} + +// NewReplicationStorageClassificationMappingID returns a new ReplicationStorageClassificationMappingId struct +func NewReplicationStorageClassificationMappingID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationStorageClassificationName string, replicationStorageClassificationMappingName string) ReplicationStorageClassificationMappingId { + return ReplicationStorageClassificationMappingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationStorageClassificationName: replicationStorageClassificationName, + ReplicationStorageClassificationMappingName: replicationStorageClassificationMappingName, + } +} + +// ParseReplicationStorageClassificationMappingID parses 'input' into a ReplicationStorageClassificationMappingId +func ParseReplicationStorageClassificationMappingID(input string) (*ReplicationStorageClassificationMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationMappingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationMappingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationStorageClassificationMappingIDInsensitively parses 'input' case-insensitively into a ReplicationStorageClassificationMappingId +// note: this method should only be used for API response data and not user input +func ParseReplicationStorageClassificationMappingIDInsensitively(input string) (*ReplicationStorageClassificationMappingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationMappingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationMappingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationStorageClassificationMappingId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationStorageClassificationName, ok = input.Parsed["replicationStorageClassificationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationStorageClassificationName", input) + } + + if id.ReplicationStorageClassificationMappingName, ok = input.Parsed["replicationStorageClassificationMappingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationStorageClassificationMappingName", input) + } + + return nil +} + +// ValidateReplicationStorageClassificationMappingID checks that 'input' can be parsed as a Replication Storage Classification Mapping ID +func ValidateReplicationStorageClassificationMappingID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationStorageClassificationMappingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Storage Classification Mapping ID +func (id ReplicationStorageClassificationMappingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationStorageClassifications/%s/replicationStorageClassificationMappings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationStorageClassificationName, id.ReplicationStorageClassificationMappingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Storage Classification Mapping ID +func (id ReplicationStorageClassificationMappingId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationStorageClassifications", "replicationStorageClassifications", "replicationStorageClassifications"), + resourceids.UserSpecifiedSegment("replicationStorageClassificationName", "replicationStorageClassificationName"), + resourceids.StaticSegment("staticReplicationStorageClassificationMappings", "replicationStorageClassificationMappings", "replicationStorageClassificationMappings"), + resourceids.UserSpecifiedSegment("replicationStorageClassificationMappingName", "replicationStorageClassificationMappingName"), + } +} + +// String returns a human-readable description of this Replication Storage Classification Mapping ID +func (id ReplicationStorageClassificationMappingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Storage Classification Name: %q", id.ReplicationStorageClassificationName), + fmt.Sprintf("Replication Storage Classification Mapping Name: %q", id.ReplicationStorageClassificationMappingName), + } + return fmt.Sprintf("Replication Storage Classification Mapping (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping_test.go new file mode 100644 index 00000000000..83299d4dc83 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_replicationstorageclassificationmapping_test.go @@ -0,0 +1,417 @@ +package replicationstorageclassificationmappings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationStorageClassificationMappingId{} + +func TestNewReplicationStorageClassificationMappingID(t *testing.T) { + id := NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName", "replicationStorageClassificationMappingName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationStorageClassificationName != "replicationStorageClassificationName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationStorageClassificationName'", id.ReplicationStorageClassificationName, "replicationStorageClassificationName") + } + + if id.ReplicationStorageClassificationMappingName != "replicationStorageClassificationMappingName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationStorageClassificationMappingName'", id.ReplicationStorageClassificationMappingName, "replicationStorageClassificationMappingName") + } +} + +func TestFormatReplicationStorageClassificationMappingID(t *testing.T) { + actual := NewReplicationStorageClassificationMappingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName", "replicationStorageClassificationMappingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/replicationStorageClassificationMappings/replicationStorageClassificationMappingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationStorageClassificationMappingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationMappingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/replicationStorageClassificationMappings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/replicationStorageClassificationMappings/replicationStorageClassificationMappingName", + Expected: &ReplicationStorageClassificationMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationStorageClassificationName: "replicationStorageClassificationName", + ReplicationStorageClassificationMappingName: "replicationStorageClassificationMappingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/replicationStorageClassificationMappings/replicationStorageClassificationMappingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationMappingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + if actual.ReplicationStorageClassificationMappingName != v.Expected.ReplicationStorageClassificationMappingName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationMappingName", v.Expected.ReplicationStorageClassificationMappingName, actual.ReplicationStorageClassificationMappingName) + } + + } +} + +func TestParseReplicationStorageClassificationMappingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationMappingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/replicationStorageClassificationMappings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/replicationStorageClassificationMappings/replicationStorageClassificationMappingName", + Expected: &ReplicationStorageClassificationMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationStorageClassificationName: "replicationStorageClassificationName", + ReplicationStorageClassificationMappingName: "replicationStorageClassificationMappingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/replicationStorageClassificationMappings/replicationStorageClassificationMappingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgS/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgNaMe", + Expected: &ReplicationStorageClassificationMappingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationStorageClassificationName: "rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE", + ReplicationStorageClassificationMappingName: "rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgS/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNmApPiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationMappingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + if actual.ReplicationStorageClassificationMappingName != v.Expected.ReplicationStorageClassificationMappingName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationMappingName", v.Expected.ReplicationStorageClassificationMappingName, actual.ReplicationStorageClassificationMappingName) + } + + } +} + +func TestSegmentsForReplicationStorageClassificationMappingId(t *testing.T) { + segments := ReplicationStorageClassificationMappingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationStorageClassificationMappingId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_vault.go new file mode 100644 index 00000000000..e792b2e3f57 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_vault.go @@ -0,0 +1,130 @@ +package replicationstorageclassificationmappings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_vault_test.go new file mode 100644 index 00000000000..fc6942dc1c9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationstorageclassificationmappings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_create.go new file mode 100644 index 00000000000..f295340750d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_create.go @@ -0,0 +1,75 @@ +package replicationstorageclassificationmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *StorageClassificationMapping +} + +// Create ... +func (c ReplicationStorageClassificationMappingsClient) Create(ctx context.Context, id ReplicationStorageClassificationMappingId, input StorageClassificationMappingInput) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationStorageClassificationMappingsClient) CreateThenPoll(ctx context.Context, id ReplicationStorageClassificationMappingId, input StorageClassificationMappingInput) 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/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_delete.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_delete.go new file mode 100644 index 00000000000..cced683f6b0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_delete.go @@ -0,0 +1,70 @@ +package replicationstorageclassificationmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 ReplicationStorageClassificationMappingsClient) Delete(ctx context.Context, id ReplicationStorageClassificationMappingId) (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 ReplicationStorageClassificationMappingsClient) DeleteThenPoll(ctx context.Context, id ReplicationStorageClassificationMappingId) 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/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_get.go new file mode 100644 index 00000000000..dfa92e4c832 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_get.go @@ -0,0 +1,53 @@ +package replicationstorageclassificationmappings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *StorageClassificationMapping +} + +// Get ... +func (c ReplicationStorageClassificationMappingsClient) Get(ctx context.Context, id ReplicationStorageClassificationMappingId) (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 StorageClassificationMapping + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_list.go new file mode 100644 index 00000000000..33b89316ca5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_list.go @@ -0,0 +1,105 @@ +package replicationstorageclassificationmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]StorageClassificationMapping +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageClassificationMapping +} + +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 ReplicationStorageClassificationMappingsClient) List(ctx context.Context, id VaultId) (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/replicationStorageClassificationMappings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StorageClassificationMapping `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 ReplicationStorageClassificationMappingsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, StorageClassificationMappingOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationStorageClassificationMappingsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate StorageClassificationMappingOperationPredicate) (result ListCompleteResult, err error) { + items := make([]StorageClassificationMapping, 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/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_listbyreplicationstorageclassifications.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_listbyreplicationstorageclassifications.go new file mode 100644 index 00000000000..17f056a2737 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/method_listbyreplicationstorageclassifications.go @@ -0,0 +1,105 @@ +package replicationstorageclassificationmappings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationStorageClassificationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageClassificationMapping +} + +type ListByReplicationStorageClassificationsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageClassificationMapping +} + +type ListByReplicationStorageClassificationsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationStorageClassificationsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationStorageClassifications ... +func (c ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassifications(ctx context.Context, id ReplicationStorageClassificationId) (result ListByReplicationStorageClassificationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationStorageClassificationsCustomPager{}, + Path: fmt.Sprintf("%s/replicationStorageClassificationMappings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StorageClassificationMapping `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationStorageClassificationsComplete retrieves all the results into a single object +func (c ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassificationsComplete(ctx context.Context, id ReplicationStorageClassificationId) (ListByReplicationStorageClassificationsCompleteResult, error) { + return c.ListByReplicationStorageClassificationsCompleteMatchingPredicate(ctx, id, StorageClassificationMappingOperationPredicate{}) +} + +// ListByReplicationStorageClassificationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassificationsCompleteMatchingPredicate(ctx context.Context, id ReplicationStorageClassificationId, predicate StorageClassificationMappingOperationPredicate) (result ListByReplicationStorageClassificationsCompleteResult, err error) { + items := make([]StorageClassificationMapping, 0) + + resp, err := c.ListByReplicationStorageClassifications(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 = ListByReplicationStorageClassificationsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/model_storageclassificationmapping.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/model_storageclassificationmapping.go new file mode 100644 index 00000000000..70642e74bca --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/model_storageclassificationmapping.go @@ -0,0 +1,12 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationMapping struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageClassificationMappingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/model_storageclassificationmappinginput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/model_storageclassificationmappinginput.go new file mode 100644 index 00000000000..158940ea210 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/model_storageclassificationmappinginput.go @@ -0,0 +1,8 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationMappingInput struct { + Properties *StorageMappingInputProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/model_storageclassificationmappingproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/model_storageclassificationmappingproperties.go new file mode 100644 index 00000000000..0b0d8c58bea --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/model_storageclassificationmappingproperties.go @@ -0,0 +1,8 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationMappingProperties struct { + TargetStorageClassificationId *string `json:"targetStorageClassificationId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/model_storagemappinginputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/model_storagemappinginputproperties.go new file mode 100644 index 00000000000..7dc80064316 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/model_storagemappinginputproperties.go @@ -0,0 +1,8 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMappingInputProperties struct { + TargetStorageClassificationId *string `json:"targetStorageClassificationId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/predicates.go new file mode 100644 index 00000000000..128f8cd8e3d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/predicates.go @@ -0,0 +1,32 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationMappingOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p StorageClassificationMappingOperationPredicate) Matches(input StorageClassificationMapping) 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/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/version.go new file mode 100644 index 00000000000..a4f14803dd2 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassificationmappings/version.go @@ -0,0 +1,10 @@ +package replicationstorageclassificationmappings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationstorageclassificationmappings/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/README.md new file mode 100644 index 00000000000..9f1040fdd6d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/README.md @@ -0,0 +1,70 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications` Documentation + +The `replicationstorageclassifications` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications" +``` + + +### Client Initialization + +```go +client := replicationstorageclassifications.NewReplicationStorageClassificationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationStorageClassificationsClient.Get` + +```go +ctx := context.TODO() +id := replicationstorageclassifications.NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName") + +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: `ReplicationStorageClassificationsClient.List` + +```go +ctx := context.TODO() +id := replicationstorageclassifications.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// 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: `ReplicationStorageClassificationsClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationstorageclassifications.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/client.go new file mode 100644 index 00000000000..15f7f47cdd1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/client.go @@ -0,0 +1,26 @@ +package replicationstorageclassifications + +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 ReplicationStorageClassificationsClient struct { + Client *resourcemanager.Client +} + +func NewReplicationStorageClassificationsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationStorageClassificationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationstorageclassifications", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationStorageClassificationsClient: %+v", err) + } + + return &ReplicationStorageClassificationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_replicationfabric.go new file mode 100644 index 00000000000..e2899f5fecb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_replicationfabric.go @@ -0,0 +1,139 @@ +package replicationstorageclassifications + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationFabricId{}) +} + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_replicationfabric_test.go new file mode 100644 index 00000000000..726bd85a5dc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationstorageclassifications + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_replicationstorageclassification.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_replicationstorageclassification.go new file mode 100644 index 00000000000..8e8996b47e8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_replicationstorageclassification.go @@ -0,0 +1,148 @@ +package replicationstorageclassifications + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationStorageClassificationId{}) +} + +var _ resourceids.ResourceId = &ReplicationStorageClassificationId{} + +// ReplicationStorageClassificationId is a struct representing the Resource ID for a Replication Storage Classification +type ReplicationStorageClassificationId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationStorageClassificationName string +} + +// NewReplicationStorageClassificationID returns a new ReplicationStorageClassificationId struct +func NewReplicationStorageClassificationID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationStorageClassificationName string) ReplicationStorageClassificationId { + return ReplicationStorageClassificationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationStorageClassificationName: replicationStorageClassificationName, + } +} + +// ParseReplicationStorageClassificationID parses 'input' into a ReplicationStorageClassificationId +func ParseReplicationStorageClassificationID(input string) (*ReplicationStorageClassificationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationStorageClassificationIDInsensitively parses 'input' case-insensitively into a ReplicationStorageClassificationId +// note: this method should only be used for API response data and not user input +func ParseReplicationStorageClassificationIDInsensitively(input string) (*ReplicationStorageClassificationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationStorageClassificationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationStorageClassificationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationStorageClassificationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationStorageClassificationName, ok = input.Parsed["replicationStorageClassificationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationStorageClassificationName", input) + } + + return nil +} + +// ValidateReplicationStorageClassificationID checks that 'input' can be parsed as a Replication Storage Classification ID +func ValidateReplicationStorageClassificationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationStorageClassificationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Storage Classification ID +func (id ReplicationStorageClassificationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationStorageClassifications/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationStorageClassificationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Storage Classification ID +func (id ReplicationStorageClassificationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationStorageClassifications", "replicationStorageClassifications", "replicationStorageClassifications"), + resourceids.UserSpecifiedSegment("replicationStorageClassificationName", "replicationStorageClassificationName"), + } +} + +// String returns a human-readable description of this Replication Storage Classification ID +func (id ReplicationStorageClassificationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Storage Classification Name: %q", id.ReplicationStorageClassificationName), + } + return fmt.Sprintf("Replication Storage Classification (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_replicationstorageclassification_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_replicationstorageclassification_test.go new file mode 100644 index 00000000000..e66a6025f8c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_replicationstorageclassification_test.go @@ -0,0 +1,372 @@ +package replicationstorageclassifications + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationStorageClassificationId{} + +func TestNewReplicationStorageClassificationID(t *testing.T) { + id := NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationStorageClassificationName != "replicationStorageClassificationName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationStorageClassificationName'", id.ReplicationStorageClassificationName, "replicationStorageClassificationName") + } +} + +func TestFormatReplicationStorageClassificationID(t *testing.T) { + actual := NewReplicationStorageClassificationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationStorageClassificationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationStorageClassificationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationStorageClassificationName: "replicationStorageClassificationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + } +} + +func TestParseReplicationStorageClassificationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationStorageClassificationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationStorageClassificationName: "replicationStorageClassificationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationStorageClassifications/replicationStorageClassificationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE", + Expected: &ReplicationStorageClassificationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationStorageClassificationName: "rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNs/rEpLiCaTiOnStOrAgEcLaSsIfIcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationStorageClassificationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationStorageClassificationName != v.Expected.ReplicationStorageClassificationName { + t.Fatalf("Expected %q but got %q for ReplicationStorageClassificationName", v.Expected.ReplicationStorageClassificationName, actual.ReplicationStorageClassificationName) + } + + } +} + +func TestSegmentsForReplicationStorageClassificationId(t *testing.T) { + segments := ReplicationStorageClassificationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationStorageClassificationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_vault.go new file mode 100644 index 00000000000..e6e8ef1f8a7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_vault.go @@ -0,0 +1,130 @@ +package replicationstorageclassifications + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_vault_test.go new file mode 100644 index 00000000000..f166541032d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationstorageclassifications + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/method_get.go new file mode 100644 index 00000000000..1a516c62385 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/method_get.go @@ -0,0 +1,53 @@ +package replicationstorageclassifications + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *StorageClassification +} + +// Get ... +func (c ReplicationStorageClassificationsClient) Get(ctx context.Context, id ReplicationStorageClassificationId) (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 StorageClassification + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/method_list.go new file mode 100644 index 00000000000..a2739887ea5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/method_list.go @@ -0,0 +1,105 @@ +package replicationstorageclassifications + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]StorageClassification +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageClassification +} + +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 ReplicationStorageClassificationsClient) List(ctx context.Context, id VaultId) (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/replicationStorageClassifications", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StorageClassification `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 ReplicationStorageClassificationsClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, StorageClassificationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationStorageClassificationsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate StorageClassificationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]StorageClassification, 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/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..8d47b1ec523 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/method_listbyreplicationfabrics.go @@ -0,0 +1,105 @@ +package replicationstorageclassifications + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StorageClassification +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StorageClassification +} + +type ListByReplicationFabricsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationFabricsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationFabrics ... +func (c ReplicationStorageClassificationsClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationFabricsCustomPager{}, + Path: fmt.Sprintf("%s/replicationStorageClassifications", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StorageClassification `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationStorageClassificationsClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, StorageClassificationOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationStorageClassificationsClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate StorageClassificationOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]StorageClassification, 0) + + resp, err := c.ListByReplicationFabrics(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 = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/model_storageclassification.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/model_storageclassification.go new file mode 100644 index 00000000000..dfe018bfb1c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/model_storageclassification.go @@ -0,0 +1,12 @@ +package replicationstorageclassifications + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassification struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageClassificationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/model_storageclassificationproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/model_storageclassificationproperties.go new file mode 100644 index 00000000000..1d077061afd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/model_storageclassificationproperties.go @@ -0,0 +1,8 @@ +package replicationstorageclassifications + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/predicates.go new file mode 100644 index 00000000000..6fae7a2f37c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/predicates.go @@ -0,0 +1,32 @@ +package replicationstorageclassifications + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageClassificationOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p StorageClassificationOperationPredicate) Matches(input StorageClassification) 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/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/version.go new file mode 100644 index 00000000000..4729d098eb0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationstorageclassifications/version.go @@ -0,0 +1,10 @@ +package replicationstorageclassifications + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationstorageclassifications/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/README.md new file mode 100644 index 00000000000..d119f417a1a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/README.md @@ -0,0 +1,48 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth` Documentation + +The `replicationvaulthealth` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth" +``` + + +### Client Initialization + +```go +client := replicationvaulthealth.NewReplicationVaultHealthClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationVaultHealthClient.Get` + +```go +ctx := context.TODO() +id := replicationvaulthealth.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +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: `ReplicationVaultHealthClient.Refresh` + +```go +ctx := context.TODO() +id := replicationvaulthealth.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +if err := client.RefreshThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/client.go new file mode 100644 index 00000000000..65b02d6236f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/client.go @@ -0,0 +1,26 @@ +package replicationvaulthealth + +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 ReplicationVaultHealthClient struct { + Client *resourcemanager.Client +} + +func NewReplicationVaultHealthClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationVaultHealthClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationvaulthealth", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationVaultHealthClient: %+v", err) + } + + return &ReplicationVaultHealthClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/constants.go new file mode 100644 index 00000000000..037b2d3c9ae --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/constants.go @@ -0,0 +1,166 @@ +package replicationvaulthealth + +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 HealthErrorCategory string + +const ( + HealthErrorCategoryAgentAutoUpdateArtifactDeleted HealthErrorCategory = "AgentAutoUpdateArtifactDeleted" + HealthErrorCategoryAgentAutoUpdateInfra HealthErrorCategory = "AgentAutoUpdateInfra" + HealthErrorCategoryAgentAutoUpdateRunAsAccount HealthErrorCategory = "AgentAutoUpdateRunAsAccount" + HealthErrorCategoryAgentAutoUpdateRunAsAccountExpired HealthErrorCategory = "AgentAutoUpdateRunAsAccountExpired" + HealthErrorCategoryAgentAutoUpdateRunAsAccountExpiry HealthErrorCategory = "AgentAutoUpdateRunAsAccountExpiry" + HealthErrorCategoryConfiguration HealthErrorCategory = "Configuration" + HealthErrorCategoryFabricInfrastructure HealthErrorCategory = "FabricInfrastructure" + HealthErrorCategoryNone HealthErrorCategory = "None" + HealthErrorCategoryReplication HealthErrorCategory = "Replication" + HealthErrorCategoryTestFailover HealthErrorCategory = "TestFailover" + HealthErrorCategoryVersionExpiry HealthErrorCategory = "VersionExpiry" +) + +func PossibleValuesForHealthErrorCategory() []string { + return []string{ + string(HealthErrorCategoryAgentAutoUpdateArtifactDeleted), + string(HealthErrorCategoryAgentAutoUpdateInfra), + string(HealthErrorCategoryAgentAutoUpdateRunAsAccount), + string(HealthErrorCategoryAgentAutoUpdateRunAsAccountExpired), + string(HealthErrorCategoryAgentAutoUpdateRunAsAccountExpiry), + string(HealthErrorCategoryConfiguration), + string(HealthErrorCategoryFabricInfrastructure), + string(HealthErrorCategoryNone), + string(HealthErrorCategoryReplication), + string(HealthErrorCategoryTestFailover), + string(HealthErrorCategoryVersionExpiry), + } +} + +func (s *HealthErrorCategory) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCategory(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCategory(input string) (*HealthErrorCategory, error) { + vals := map[string]HealthErrorCategory{ + "agentautoupdateartifactdeleted": HealthErrorCategoryAgentAutoUpdateArtifactDeleted, + "agentautoupdateinfra": HealthErrorCategoryAgentAutoUpdateInfra, + "agentautoupdaterunasaccount": HealthErrorCategoryAgentAutoUpdateRunAsAccount, + "agentautoupdaterunasaccountexpired": HealthErrorCategoryAgentAutoUpdateRunAsAccountExpired, + "agentautoupdaterunasaccountexpiry": HealthErrorCategoryAgentAutoUpdateRunAsAccountExpiry, + "configuration": HealthErrorCategoryConfiguration, + "fabricinfrastructure": HealthErrorCategoryFabricInfrastructure, + "none": HealthErrorCategoryNone, + "replication": HealthErrorCategoryReplication, + "testfailover": HealthErrorCategoryTestFailover, + "versionexpiry": HealthErrorCategoryVersionExpiry, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCategory(input) + return &out, nil +} + +type HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} + +type Severity string + +const ( + SeverityError Severity = "Error" + SeverityInfo Severity = "Info" + SeverityNONE Severity = "NONE" + SeverityWarning Severity = "Warning" +) + +func PossibleValuesForSeverity() []string { + return []string{ + string(SeverityError), + string(SeverityInfo), + string(SeverityNONE), + string(SeverityWarning), + } +} + +func (s *Severity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSeverity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSeverity(input string) (*Severity, error) { + vals := map[string]Severity{ + "error": SeverityError, + "info": SeverityInfo, + "none": SeverityNONE, + "warning": SeverityWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Severity(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/id_vault.go new file mode 100644 index 00000000000..bfec839dc80 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/id_vault.go @@ -0,0 +1,130 @@ +package replicationvaulthealth + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/id_vault_test.go new file mode 100644 index 00000000000..1eed0241695 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationvaulthealth + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/method_get.go new file mode 100644 index 00000000000..99edaf64697 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/method_get.go @@ -0,0 +1,54 @@ +package replicationvaulthealth + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *VaultHealthDetails +} + +// Get ... +func (c ReplicationVaultHealthClient) Get(ctx context.Context, id VaultId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationVaultHealth", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VaultHealthDetails + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/method_refresh.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/method_refresh.go new file mode 100644 index 00000000000..17fd7e306a1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/method_refresh.go @@ -0,0 +1,71 @@ +package replicationvaulthealth + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RefreshOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VaultHealthDetails +} + +// Refresh ... +func (c ReplicationVaultHealthClient) Refresh(ctx context.Context, id VaultId) (result RefreshOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/replicationVaultHealth/default/refresh", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RefreshThenPoll performs Refresh then polls until it's completed +func (c ReplicationVaultHealthClient) RefreshThenPoll(ctx context.Context, id VaultId) error { + result, err := c.Refresh(ctx, id) + if err != nil { + return fmt.Errorf("performing Refresh: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Refresh: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_healtherror.go new file mode 100644 index 00000000000..a1cded61cd6 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationvaulthealth + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_healtherrorsummary.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_healtherrorsummary.go new file mode 100644 index 00000000000..7a99b52ddd8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_healtherrorsummary.go @@ -0,0 +1,14 @@ +package replicationvaulthealth + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HealthErrorSummary struct { + AffectedResourceCorrelationIds *[]string `json:"affectedResourceCorrelationIds,omitempty"` + AffectedResourceSubtype *string `json:"affectedResourceSubtype,omitempty"` + AffectedResourceType *string `json:"affectedResourceType,omitempty"` + Category *HealthErrorCategory `json:"category,omitempty"` + Severity *Severity `json:"severity,omitempty"` + SummaryCode *string `json:"summaryCode,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_innerhealtherror.go new file mode 100644 index 00000000000..f01babb170f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationvaulthealth + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_resourcehealthsummary.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_resourcehealthsummary.go new file mode 100644 index 00000000000..6238fa00867 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_resourcehealthsummary.go @@ -0,0 +1,10 @@ +package replicationvaulthealth + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthSummary struct { + CategorizedResourceCounts *map[string]int64 `json:"categorizedResourceCounts,omitempty"` + Issues *[]HealthErrorSummary `json:"issues,omitempty"` + ResourceCount *int64 `json:"resourceCount,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_vaulthealthdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_vaulthealthdetails.go new file mode 100644 index 00000000000..2c0736a7902 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_vaulthealthdetails.go @@ -0,0 +1,12 @@ +package replicationvaulthealth + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultHealthDetails struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VaultHealthProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_vaulthealthproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_vaulthealthproperties.go new file mode 100644 index 00000000000..d17dd6d82bc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/model_vaulthealthproperties.go @@ -0,0 +1,11 @@ +package replicationvaulthealth + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultHealthProperties struct { + ContainersHealth *ResourceHealthSummary `json:"containersHealth,omitempty"` + FabricsHealth *ResourceHealthSummary `json:"fabricsHealth,omitempty"` + ProtectedItemsHealth *ResourceHealthSummary `json:"protectedItemsHealth,omitempty"` + VaultErrors *[]HealthError `json:"vaultErrors,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/version.go new file mode 100644 index 00000000000..e2f369e86c5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaulthealth/version.go @@ -0,0 +1,10 @@ +package replicationvaulthealth + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationvaulthealth/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/README.md new file mode 100644 index 00000000000..13e52c2f797 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/README.md @@ -0,0 +1,70 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting` Documentation + +The `replicationvaultsetting` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting" +``` + + +### Client Initialization + +```go +client := replicationvaultsetting.NewReplicationVaultSettingClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationVaultSettingClient.Create` + +```go +ctx := context.TODO() +id := replicationvaultsetting.NewReplicationVaultSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationVaultSettingName") + +payload := replicationvaultsetting.VaultSettingCreationInput{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationVaultSettingClient.Get` + +```go +ctx := context.TODO() +id := replicationvaultsetting.NewReplicationVaultSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationVaultSettingName") + +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: `ReplicationVaultSettingClient.List` + +```go +ctx := context.TODO() +id := replicationvaultsetting.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/client.go new file mode 100644 index 00000000000..614fa0058cc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/client.go @@ -0,0 +1,26 @@ +package replicationvaultsetting + +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 ReplicationVaultSettingClient struct { + Client *resourcemanager.Client +} + +func NewReplicationVaultSettingClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationVaultSettingClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationvaultsetting", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationVaultSettingClient: %+v", err) + } + + return &ReplicationVaultSettingClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/id_replicationvaultsetting.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/id_replicationvaultsetting.go new file mode 100644 index 00000000000..ecf9719a633 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/id_replicationvaultsetting.go @@ -0,0 +1,139 @@ +package replicationvaultsetting + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationVaultSettingId{}) +} + +var _ resourceids.ResourceId = &ReplicationVaultSettingId{} + +// ReplicationVaultSettingId is a struct representing the Resource ID for a Replication Vault Setting +type ReplicationVaultSettingId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationVaultSettingName string +} + +// NewReplicationVaultSettingID returns a new ReplicationVaultSettingId struct +func NewReplicationVaultSettingID(subscriptionId string, resourceGroupName string, vaultName string, replicationVaultSettingName string) ReplicationVaultSettingId { + return ReplicationVaultSettingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationVaultSettingName: replicationVaultSettingName, + } +} + +// ParseReplicationVaultSettingID parses 'input' into a ReplicationVaultSettingId +func ParseReplicationVaultSettingID(input string) (*ReplicationVaultSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationVaultSettingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationVaultSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationVaultSettingIDInsensitively parses 'input' case-insensitively into a ReplicationVaultSettingId +// note: this method should only be used for API response data and not user input +func ParseReplicationVaultSettingIDInsensitively(input string) (*ReplicationVaultSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationVaultSettingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationVaultSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationVaultSettingId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationVaultSettingName, ok = input.Parsed["replicationVaultSettingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationVaultSettingName", input) + } + + return nil +} + +// ValidateReplicationVaultSettingID checks that 'input' can be parsed as a Replication Vault Setting ID +func ValidateReplicationVaultSettingID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationVaultSettingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Vault Setting ID +func (id ReplicationVaultSettingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationVaultSettings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationVaultSettingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Vault Setting ID +func (id ReplicationVaultSettingId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationVaultSettings", "replicationVaultSettings", "replicationVaultSettings"), + resourceids.UserSpecifiedSegment("replicationVaultSettingName", "replicationVaultSettingName"), + } +} + +// String returns a human-readable description of this Replication Vault Setting ID +func (id ReplicationVaultSettingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Vault Setting Name: %q", id.ReplicationVaultSettingName), + } + return fmt.Sprintf("Replication Vault Setting (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/id_replicationvaultsetting_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/id_replicationvaultsetting_test.go new file mode 100644 index 00000000000..bf6d3aeb9ce --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/id_replicationvaultsetting_test.go @@ -0,0 +1,327 @@ +package replicationvaultsetting + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationVaultSettingId{} + +func TestNewReplicationVaultSettingID(t *testing.T) { + id := NewReplicationVaultSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationVaultSettingName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationVaultSettingName != "replicationVaultSettingName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationVaultSettingName'", id.ReplicationVaultSettingName, "replicationVaultSettingName") + } +} + +func TestFormatReplicationVaultSettingID(t *testing.T) { + actual := NewReplicationVaultSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationVaultSettingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationVaultSettings/replicationVaultSettingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationVaultSettingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationVaultSettingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationVaultSettings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationVaultSettings/replicationVaultSettingName", + Expected: &ReplicationVaultSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationVaultSettingName: "replicationVaultSettingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationVaultSettings/replicationVaultSettingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationVaultSettingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationVaultSettingName != v.Expected.ReplicationVaultSettingName { + t.Fatalf("Expected %q but got %q for ReplicationVaultSettingName", v.Expected.ReplicationVaultSettingName, actual.ReplicationVaultSettingName) + } + + } +} + +func TestParseReplicationVaultSettingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationVaultSettingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationVaultSettings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnVaUlTsEtTiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationVaultSettings/replicationVaultSettingName", + Expected: &ReplicationVaultSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationVaultSettingName: "replicationVaultSettingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationVaultSettings/replicationVaultSettingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnVaUlTsEtTiNgS/rEpLiCaTiOnVaUlTsEtTiNgNaMe", + Expected: &ReplicationVaultSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationVaultSettingName: "rEpLiCaTiOnVaUlTsEtTiNgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnVaUlTsEtTiNgS/rEpLiCaTiOnVaUlTsEtTiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationVaultSettingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationVaultSettingName != v.Expected.ReplicationVaultSettingName { + t.Fatalf("Expected %q but got %q for ReplicationVaultSettingName", v.Expected.ReplicationVaultSettingName, actual.ReplicationVaultSettingName) + } + + } +} + +func TestSegmentsForReplicationVaultSettingId(t *testing.T) { + segments := ReplicationVaultSettingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationVaultSettingId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/id_vault.go new file mode 100644 index 00000000000..26d5327d79b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/id_vault.go @@ -0,0 +1,130 @@ +package replicationvaultsetting + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/id_vault_test.go new file mode 100644 index 00000000000..db40ac61c76 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationvaultsetting + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/method_create.go new file mode 100644 index 00000000000..2207eda514a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/method_create.go @@ -0,0 +1,74 @@ +package replicationvaultsetting + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *VaultSetting +} + +// Create ... +func (c ReplicationVaultSettingClient) Create(ctx context.Context, id ReplicationVaultSettingId, input VaultSettingCreationInput) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationVaultSettingClient) CreateThenPoll(ctx context.Context, id ReplicationVaultSettingId, input VaultSettingCreationInput) 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/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/method_get.go new file mode 100644 index 00000000000..1780e8632e3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/method_get.go @@ -0,0 +1,53 @@ +package replicationvaultsetting + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *VaultSetting +} + +// Get ... +func (c ReplicationVaultSettingClient) Get(ctx context.Context, id ReplicationVaultSettingId) (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 VaultSetting + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/method_list.go new file mode 100644 index 00000000000..8887bc084fc --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/method_list.go @@ -0,0 +1,105 @@ +package replicationvaultsetting + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]VaultSetting +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VaultSetting +} + +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 ReplicationVaultSettingClient) List(ctx context.Context, id VaultId) (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/replicationVaultSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VaultSetting `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 ReplicationVaultSettingClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VaultSettingOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationVaultSettingClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate VaultSettingOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VaultSetting, 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/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/model_vaultsetting.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/model_vaultsetting.go new file mode 100644 index 00000000000..da949586ad3 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/model_vaultsetting.go @@ -0,0 +1,12 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSetting struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VaultSettingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/model_vaultsettingcreationinput.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/model_vaultsettingcreationinput.go new file mode 100644 index 00000000000..ea6dddb61aa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/model_vaultsettingcreationinput.go @@ -0,0 +1,8 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSettingCreationInput struct { + Properties VaultSettingCreationInputProperties `json:"properties"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/model_vaultsettingcreationinputproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/model_vaultsettingcreationinputproperties.go new file mode 100644 index 00000000000..d7654ac5546 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/model_vaultsettingcreationinputproperties.go @@ -0,0 +1,9 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSettingCreationInputProperties struct { + MigrationSolutionId *string `json:"migrationSolutionId,omitempty"` + VMwareToAzureProviderType *string `json:"vmwareToAzureProviderType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/model_vaultsettingproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/model_vaultsettingproperties.go new file mode 100644 index 00000000000..c90471f30f5 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/model_vaultsettingproperties.go @@ -0,0 +1,9 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSettingProperties struct { + MigrationSolutionId *string `json:"migrationSolutionId,omitempty"` + VMwareToAzureProviderType *string `json:"vmwareToAzureProviderType,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/predicates.go new file mode 100644 index 00000000000..8e5065553c1 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/predicates.go @@ -0,0 +1,32 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSettingOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p VaultSettingOperationPredicate) Matches(input VaultSetting) 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/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/version.go new file mode 100644 index 00000000000..55e0ae614c0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvaultsetting/version.go @@ -0,0 +1,10 @@ +package replicationvaultsetting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationvaultsetting/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/README.md new file mode 100644 index 00000000000..9f0c7e69415 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters` Documentation + +The `replicationvcenters` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/replicationvcenters" +``` + + +### Client Initialization + +```go +client := replicationvcenters.NewReplicationvCentersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationvCentersClient.Create` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationvCenterName") + +payload := replicationvcenters.AddVCenterRequest{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationvCentersClient.Delete` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationvCenterName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReplicationvCentersClient.Get` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationvCenterName") + +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: `ReplicationvCentersClient.List` + +```go +ctx := context.TODO() +id := replicationvcenters.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +// 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: `ReplicationvCentersClient.ListByReplicationFabrics` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + +// alternatively `client.ListByReplicationFabrics(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationFabricsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ReplicationvCentersClient.Update` + +```go +ctx := context.TODO() +id := replicationvcenters.NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationvCenterName") + +payload := replicationvcenters.UpdateVCenterRequest{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/client.go new file mode 100644 index 00000000000..57e9dd9ecaa --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/client.go @@ -0,0 +1,26 @@ +package replicationvcenters + +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 ReplicationvCentersClient struct { + Client *resourcemanager.Client +} + +func NewReplicationvCentersClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationvCentersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "replicationvcenters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationvCentersClient: %+v", err) + } + + return &ReplicationvCentersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/constants.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/constants.go new file mode 100644 index 00000000000..5eb916fd9d8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/constants.go @@ -0,0 +1,51 @@ +package replicationvcenters + +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 HealthErrorCustomerResolvability string + +const ( + HealthErrorCustomerResolvabilityAllowed HealthErrorCustomerResolvability = "Allowed" + HealthErrorCustomerResolvabilityNotAllowed HealthErrorCustomerResolvability = "NotAllowed" +) + +func PossibleValuesForHealthErrorCustomerResolvability() []string { + return []string{ + string(HealthErrorCustomerResolvabilityAllowed), + string(HealthErrorCustomerResolvabilityNotAllowed), + } +} + +func (s *HealthErrorCustomerResolvability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHealthErrorCustomerResolvability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHealthErrorCustomerResolvability(input string) (*HealthErrorCustomerResolvability, error) { + vals := map[string]HealthErrorCustomerResolvability{ + "allowed": HealthErrorCustomerResolvabilityAllowed, + "notallowed": HealthErrorCustomerResolvabilityNotAllowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthErrorCustomerResolvability(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_replicationfabric.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_replicationfabric.go new file mode 100644 index 00000000000..02266219cb8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_replicationfabric.go @@ -0,0 +1,139 @@ +package replicationvcenters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationFabricId{}) +} + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +// ReplicationFabricId is a struct representing the Resource ID for a Replication Fabric +type ReplicationFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string +} + +// NewReplicationFabricID returns a new ReplicationFabricId struct +func NewReplicationFabricID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string) ReplicationFabricId { + return ReplicationFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + } +} + +// ParseReplicationFabricID parses 'input' into a ReplicationFabricId +func ParseReplicationFabricID(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationFabricIDInsensitively parses 'input' case-insensitively into a ReplicationFabricId +// note: this method should only be used for API response data and not user input +func ParseReplicationFabricIDInsensitively(input string) (*ReplicationFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationFabricId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationFabricId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + return nil +} + +// ValidateReplicationFabricID checks that 'input' can be parsed as a Replication Fabric ID +func ValidateReplicationFabricID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Fabric ID +func (id ReplicationFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Fabric ID +func (id ReplicationFabricId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + } +} + +// String returns a human-readable description of this Replication Fabric ID +func (id ReplicationFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + } + return fmt.Sprintf("Replication Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_replicationfabric_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_replicationfabric_test.go new file mode 100644 index 00000000000..34ad51f05fd --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_replicationfabric_test.go @@ -0,0 +1,327 @@ +package replicationvcenters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationFabricId{} + +func TestNewReplicationFabricID(t *testing.T) { + id := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } +} + +func TestFormatReplicationFabricID(t *testing.T) { + actual := NewReplicationFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestParseReplicationFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Expected: &ReplicationFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationFabricIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + } +} + +func TestSegmentsForReplicationFabricId(t *testing.T) { + segments := ReplicationFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationFabricId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_replicationvcenter.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_replicationvcenter.go new file mode 100644 index 00000000000..0737f2b9eb7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_replicationvcenter.go @@ -0,0 +1,148 @@ +package replicationvcenters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationvCenterId{}) +} + +var _ resourceids.ResourceId = &ReplicationvCenterId{} + +// ReplicationvCenterId is a struct representing the Resource ID for a Replicationv Center +type ReplicationvCenterId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationvCenterName string +} + +// NewReplicationvCenterID returns a new ReplicationvCenterId struct +func NewReplicationvCenterID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationvCenterName string) ReplicationvCenterId { + return ReplicationvCenterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationvCenterName: replicationvCenterName, + } +} + +// ParseReplicationvCenterID parses 'input' into a ReplicationvCenterId +func ParseReplicationvCenterID(input string) (*ReplicationvCenterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationvCenterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationvCenterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationvCenterIDInsensitively parses 'input' case-insensitively into a ReplicationvCenterId +// note: this method should only be used for API response data and not user input +func ParseReplicationvCenterIDInsensitively(input string) (*ReplicationvCenterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationvCenterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationvCenterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationvCenterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationvCenterName, ok = input.Parsed["replicationvCenterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationvCenterName", input) + } + + return nil +} + +// ValidateReplicationvCenterID checks that 'input' can be parsed as a Replicationv Center ID +func ValidateReplicationvCenterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationvCenterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replicationv Center ID +func (id ReplicationvCenterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationvCenters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationvCenterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replicationv Center ID +func (id ReplicationvCenterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationvCenters", "replicationvCenters", "replicationvCenters"), + resourceids.UserSpecifiedSegment("replicationvCenterName", "replicationvCenterName"), + } +} + +// String returns a human-readable description of this Replicationv Center ID +func (id ReplicationvCenterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replicationv Center Name: %q", id.ReplicationvCenterName), + } + return fmt.Sprintf("Replicationv Center (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_replicationvcenter_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_replicationvcenter_test.go new file mode 100644 index 00000000000..9825c94a29a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_replicationvcenter_test.go @@ -0,0 +1,372 @@ +package replicationvcenters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationvCenterId{} + +func TestNewReplicationvCenterID(t *testing.T) { + id := NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationvCenterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationvCenterName != "replicationvCenterName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationvCenterName'", id.ReplicationvCenterName, "replicationvCenterName") + } +} + +func TestFormatReplicationvCenterID(t *testing.T) { + actual := NewReplicationvCenterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationvCenterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationvCenters/replicationvCenterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationvCenterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationvCenterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationvCenters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationvCenters/replicationvCenterName", + Expected: &ReplicationvCenterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationvCenterName: "replicationvCenterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationvCenters/replicationvCenterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationvCenterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationvCenterName != v.Expected.ReplicationvCenterName { + t.Fatalf("Expected %q but got %q for ReplicationvCenterName", v.Expected.ReplicationvCenterName, actual.ReplicationvCenterName) + } + + } +} + +func TestParseReplicationvCenterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationvCenterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationvCenters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnVcEnTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationvCenters/replicationvCenterName", + Expected: &ReplicationvCenterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationvCenterName: "replicationvCenterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationvCenters/replicationvCenterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnVcEnTeRs/rEpLiCaTiOnVcEnTeRnAmE", + Expected: &ReplicationvCenterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationvCenterName: "rEpLiCaTiOnVcEnTeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnVcEnTeRs/rEpLiCaTiOnVcEnTeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationvCenterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationvCenterName != v.Expected.ReplicationvCenterName { + t.Fatalf("Expected %q but got %q for ReplicationvCenterName", v.Expected.ReplicationvCenterName, actual.ReplicationvCenterName) + } + + } +} + +func TestSegmentsForReplicationvCenterId(t *testing.T) { + segments := ReplicationvCenterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationvCenterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_vault.go new file mode 100644 index 00000000000..e37ff91d564 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_vault.go @@ -0,0 +1,130 @@ +package replicationvcenters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_vault_test.go new file mode 100644 index 00000000000..d474d05200f --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationvcenters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_create.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_create.go new file mode 100644 index 00000000000..b08a9b622c7 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_create.go @@ -0,0 +1,75 @@ +package replicationvcenters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *VCenter +} + +// Create ... +func (c ReplicationvCentersClient) Create(ctx context.Context, id ReplicationvCenterId, input AddVCenterRequest) (result CreateOperationResponse, 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ReplicationvCentersClient) CreateThenPoll(ctx context.Context, id ReplicationvCenterId, input AddVCenterRequest) 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/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_delete.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_delete.go new file mode 100644 index 00000000000..67f5d8e7a5d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_delete.go @@ -0,0 +1,70 @@ +package replicationvcenters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 ReplicationvCentersClient) Delete(ctx context.Context, id ReplicationvCenterId) (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 ReplicationvCentersClient) DeleteThenPoll(ctx context.Context, id ReplicationvCenterId) 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/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_get.go new file mode 100644 index 00000000000..624c667672c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_get.go @@ -0,0 +1,53 @@ +package replicationvcenters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *VCenter +} + +// Get ... +func (c ReplicationvCentersClient) Get(ctx context.Context, id ReplicationvCenterId) (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 VCenter + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_list.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_list.go new file mode 100644 index 00000000000..f92559a8f20 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_list.go @@ -0,0 +1,105 @@ +package replicationvcenters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]VCenter +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VCenter +} + +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 ReplicationvCentersClient) List(ctx context.Context, id VaultId) (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/replicationvCenters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VCenter `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 ReplicationvCentersClient) ListComplete(ctx context.Context, id VaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VCenterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationvCentersClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate VCenterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VCenter, 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/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_listbyreplicationfabrics.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_listbyreplicationfabrics.go new file mode 100644 index 00000000000..2c99a1a6fea --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_listbyreplicationfabrics.go @@ -0,0 +1,105 @@ +package replicationvcenters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationFabricsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VCenter +} + +type ListByReplicationFabricsCompleteResult struct { + LatestHttpResponse *http.Response + Items []VCenter +} + +type ListByReplicationFabricsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationFabricsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationFabrics ... +func (c ReplicationvCentersClient) ListByReplicationFabrics(ctx context.Context, id ReplicationFabricId) (result ListByReplicationFabricsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationFabricsCustomPager{}, + Path: fmt.Sprintf("%s/replicationvCenters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VCenter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationFabricsComplete retrieves all the results into a single object +func (c ReplicationvCentersClient) ListByReplicationFabricsComplete(ctx context.Context, id ReplicationFabricId) (ListByReplicationFabricsCompleteResult, error) { + return c.ListByReplicationFabricsCompleteMatchingPredicate(ctx, id, VCenterOperationPredicate{}) +} + +// ListByReplicationFabricsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReplicationvCentersClient) ListByReplicationFabricsCompleteMatchingPredicate(ctx context.Context, id ReplicationFabricId, predicate VCenterOperationPredicate) (result ListByReplicationFabricsCompleteResult, err error) { + items := make([]VCenter, 0) + + resp, err := c.ListByReplicationFabrics(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 = ListByReplicationFabricsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_update.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_update.go new file mode 100644 index 00000000000..8b93d0669a9 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/method_update.go @@ -0,0 +1,75 @@ +package replicationvcenters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *VCenter +} + +// Update ... +func (c ReplicationvCentersClient) Update(ctx context.Context, id ReplicationvCenterId, input UpdateVCenterRequest) (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 ReplicationvCentersClient) UpdateThenPoll(ctx context.Context, id ReplicationvCenterId, input UpdateVCenterRequest) 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/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_addvcenterrequest.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_addvcenterrequest.go new file mode 100644 index 00000000000..8bc14e86c5c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_addvcenterrequest.go @@ -0,0 +1,8 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddVCenterRequest struct { + Properties *AddVCenterRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_addvcenterrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_addvcenterrequestproperties.go new file mode 100644 index 00000000000..3904def79d8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_addvcenterrequestproperties.go @@ -0,0 +1,12 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddVCenterRequestProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Port *string `json:"port,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_healtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_healtherror.go new file mode 100644 index 00000000000..915bd6578cf --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_healtherror.go @@ -0,0 +1,40 @@ +package replicationvcenters + +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 HealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + InnerHealthErrors *[]InnerHealthError `json:"innerHealthErrors,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *HealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *HealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_innerhealtherror.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_innerhealtherror.go new file mode 100644 index 00000000000..5ed6fc2fe05 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_innerhealtherror.go @@ -0,0 +1,39 @@ +package replicationvcenters + +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 InnerHealthError struct { + CreationTimeUtc *string `json:"creationTimeUtc,omitempty"` + CustomerResolvability *HealthErrorCustomerResolvability `json:"customerResolvability,omitempty"` + EntityId *string `json:"entityId,omitempty"` + ErrorCategory *string `json:"errorCategory,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorId *string `json:"errorId,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorSource *string `json:"errorSource,omitempty"` + ErrorType *string `json:"errorType,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + SummaryMessage *string `json:"summaryMessage,omitempty"` +} + +func (o *InnerHealthError) GetCreationTimeUtcAsTime() (*time.Time, error) { + if o.CreationTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *InnerHealthError) SetCreationTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_updatevcenterrequest.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_updatevcenterrequest.go new file mode 100644 index 00000000000..c9ab295622d --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_updatevcenterrequest.go @@ -0,0 +1,8 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateVCenterRequest struct { + Properties *UpdateVCenterRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_updatevcenterrequestproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_updatevcenterrequestproperties.go new file mode 100644 index 00000000000..9c02f563369 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_updatevcenterrequestproperties.go @@ -0,0 +1,12 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateVCenterRequestProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Port *string `json:"port,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_vcenter.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_vcenter.go new file mode 100644 index 00000000000..5f8c2b26c1e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_vcenter.go @@ -0,0 +1,12 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VCenter struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VCenterProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_vcenterproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_vcenterproperties.go new file mode 100644 index 00000000000..9f4d3394f62 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/model_vcenterproperties.go @@ -0,0 +1,36 @@ +package replicationvcenters + +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 VCenterProperties struct { + DiscoveryStatus *string `json:"discoveryStatus,omitempty"` + FabricArmResourceName *string `json:"fabricArmResourceName,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InfrastructureId *string `json:"infrastructureId,omitempty"` + InternalId *string `json:"internalId,omitempty"` + LastHeartbeat *string `json:"lastHeartbeat,omitempty"` + Port *string `json:"port,omitempty"` + ProcessServerId *string `json:"processServerId,omitempty"` + RunAsAccountId *string `json:"runAsAccountId,omitempty"` +} + +func (o *VCenterProperties) GetLastHeartbeatAsTime() (*time.Time, error) { + if o.LastHeartbeat == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastHeartbeat, "2006-01-02T15:04:05Z07:00") +} + +func (o *VCenterProperties) SetLastHeartbeatAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastHeartbeat = &formatted +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/predicates.go new file mode 100644 index 00000000000..604db32ccd0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/predicates.go @@ -0,0 +1,32 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VCenterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p VCenterOperationPredicate) Matches(input VCenter) 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/recoveryservicessiterecovery/2025-02-01/replicationvcenters/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/version.go new file mode 100644 index 00000000000..9c90aa4be80 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/replicationvcenters/version.go @@ -0,0 +1,10 @@ +package replicationvcenters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/replicationvcenters/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/README.md new file mode 100644 index 00000000000..70c439ed389 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems` Documentation + +The `supportedoperatingsystems` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems" +``` + + +### Client Initialization + +```go +client := supportedoperatingsystems.NewSupportedOperatingSystemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SupportedOperatingSystemsClient.Get` + +```go +ctx := context.TODO() +id := supportedoperatingsystems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + +read, err := client.Get(ctx, id, supportedoperatingsystems.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/client.go new file mode 100644 index 00000000000..b895d9b8fd4 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/client.go @@ -0,0 +1,26 @@ +package supportedoperatingsystems + +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 SupportedOperatingSystemsClient struct { + Client *resourcemanager.Client +} + +func NewSupportedOperatingSystemsClientWithBaseURI(sdkApi sdkEnv.Api) (*SupportedOperatingSystemsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "supportedoperatingsystems", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SupportedOperatingSystemsClient: %+v", err) + } + + return &SupportedOperatingSystemsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/id_vault.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/id_vault.go new file mode 100644 index 00000000000..2577775d89c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/id_vault.go @@ -0,0 +1,130 @@ +package supportedoperatingsystems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/id_vault_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/id_vault_test.go new file mode 100644 index 00000000000..84334cd878a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/id_vault_test.go @@ -0,0 +1,282 @@ +package supportedoperatingsystems + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/method_get.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/method_get.go new file mode 100644 index 00000000000..a3839b3d736 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/method_get.go @@ -0,0 +1,83 @@ +package supportedoperatingsystems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *SupportedOperatingSystems +} + +type GetOperationOptions struct { + InstanceType *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.InstanceType != nil { + out.Append("instanceType", fmt.Sprintf("%v", *o.InstanceType)) + } + return &out +} + +// Get ... +func (c SupportedOperatingSystemsClient) Get(ctx context.Context, id VaultId, 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: fmt.Sprintf("%s/replicationSupportedOperatingSystems", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SupportedOperatingSystems + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_osversionwrapper.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_osversionwrapper.go new file mode 100644 index 00000000000..af334b23ea8 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_osversionwrapper.go @@ -0,0 +1,9 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSVersionWrapper struct { + ServicePack *string `json:"servicePack,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_supportedoperatingsystems.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_supportedoperatingsystems.go new file mode 100644 index 00000000000..2d7bee64192 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_supportedoperatingsystems.go @@ -0,0 +1,12 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedOperatingSystems struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SupportedOSProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_supportedosdetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_supportedosdetails.go new file mode 100644 index 00000000000..b89ec6cfe3a --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_supportedosdetails.go @@ -0,0 +1,10 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedOSDetails struct { + OsName *string `json:"osName,omitempty"` + OsType *string `json:"osType,omitempty"` + OsVersions *[]OSVersionWrapper `json:"osVersions,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_supportedosproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_supportedosproperties.go new file mode 100644 index 00000000000..ee9acfc9a81 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_supportedosproperties.go @@ -0,0 +1,8 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedOSProperties struct { + SupportedOsList *[]SupportedOSProperty `json:"supportedOsList,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_supportedosproperty.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_supportedosproperty.go new file mode 100644 index 00000000000..e9f60b43c0b --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/model_supportedosproperty.go @@ -0,0 +1,9 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedOSProperty struct { + InstanceType *string `json:"instanceType,omitempty"` + SupportedOs *[]SupportedOSDetails `json:"supportedOs,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/version.go new file mode 100644 index 00000000000..ff5dbb43b98 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/supportedoperatingsystems/version.go @@ -0,0 +1,10 @@ +package supportedoperatingsystems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/supportedoperatingsystems/2025-02-01" +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/README.md b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/README.md new file mode 100644 index 00000000000..a8e6d98ed8c --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes` Documentation + +The `targetcomputesizes` SDK allows for interaction with Azure Resource Manager `recoveryservicessiterecovery` (API Version `2025-02-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/recoveryservicessiterecovery/2025-02-01/targetcomputesizes" +``` + + +### Client Initialization + +```go +client := targetcomputesizes.NewTargetComputeSizesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `TargetComputeSizesClient.ListByReplicationProtectedItems` + +```go +ctx := context.TODO() +id := targetcomputesizes.NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + +// alternatively `client.ListByReplicationProtectedItems(ctx, id)` can be used to do batched pagination +items, err := client.ListByReplicationProtectedItemsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/client.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/client.go new file mode 100644 index 00000000000..9e8a8315990 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/client.go @@ -0,0 +1,26 @@ +package targetcomputesizes + +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 TargetComputeSizesClient struct { + Client *resourcemanager.Client +} + +func NewTargetComputeSizesClientWithBaseURI(sdkApi sdkEnv.Api) (*TargetComputeSizesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "targetcomputesizes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TargetComputeSizesClient: %+v", err) + } + + return &TargetComputeSizesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/id_replicationprotecteditem.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/id_replicationprotecteditem.go new file mode 100644 index 00000000000..980d5cc9c99 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/id_replicationprotecteditem.go @@ -0,0 +1,157 @@ +package targetcomputesizes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicationProtectedItemId{}) +} + +var _ resourceids.ResourceId = &ReplicationProtectedItemId{} + +// ReplicationProtectedItemId is a struct representing the Resource ID for a Replication Protected Item +type ReplicationProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + ReplicationFabricName string + ReplicationProtectionContainerName string + ReplicationProtectedItemName string +} + +// NewReplicationProtectedItemID returns a new ReplicationProtectedItemId struct +func NewReplicationProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, replicationFabricName string, replicationProtectionContainerName string, replicationProtectedItemName string) ReplicationProtectedItemId { + return ReplicationProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + ReplicationFabricName: replicationFabricName, + ReplicationProtectionContainerName: replicationProtectionContainerName, + ReplicationProtectedItemName: replicationProtectedItemName, + } +} + +// ParseReplicationProtectedItemID parses 'input' into a ReplicationProtectedItemId +func ParseReplicationProtectedItemID(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicationProtectedItemIDInsensitively parses 'input' case-insensitively into a ReplicationProtectedItemId +// note: this method should only be used for API response data and not user input +func ParseReplicationProtectedItemIDInsensitively(input string) (*ReplicationProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicationProtectedItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicationProtectedItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicationProtectedItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.ReplicationFabricName, ok = input.Parsed["replicationFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationFabricName", input) + } + + if id.ReplicationProtectionContainerName, ok = input.Parsed["replicationProtectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectionContainerName", input) + } + + if id.ReplicationProtectedItemName, ok = input.Parsed["replicationProtectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicationProtectedItemName", input) + } + + return nil +} + +// ValidateReplicationProtectedItemID checks that 'input' can be parsed as a Replication Protected Item ID +func ValidateReplicationProtectedItemID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReplicationProtectedItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replication Protected Item ID +func (id ReplicationProtectedItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/replicationFabrics/%s/replicationProtectionContainers/%s/replicationProtectedItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.ReplicationFabricName, id.ReplicationProtectionContainerName, id.ReplicationProtectedItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replication Protected Item ID +func (id ReplicationProtectedItemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultName"), + resourceids.StaticSegment("staticReplicationFabrics", "replicationFabrics", "replicationFabrics"), + resourceids.UserSpecifiedSegment("replicationFabricName", "replicationFabricName"), + resourceids.StaticSegment("staticReplicationProtectionContainers", "replicationProtectionContainers", "replicationProtectionContainers"), + resourceids.UserSpecifiedSegment("replicationProtectionContainerName", "replicationProtectionContainerName"), + resourceids.StaticSegment("staticReplicationProtectedItems", "replicationProtectedItems", "replicationProtectedItems"), + resourceids.UserSpecifiedSegment("replicationProtectedItemName", "replicationProtectedItemName"), + } +} + +// String returns a human-readable description of this Replication Protected Item ID +func (id ReplicationProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Replication Fabric Name: %q", id.ReplicationFabricName), + fmt.Sprintf("Replication Protection Container Name: %q", id.ReplicationProtectionContainerName), + fmt.Sprintf("Replication Protected Item Name: %q", id.ReplicationProtectedItemName), + } + return fmt.Sprintf("Replication Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/id_replicationprotecteditem_test.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/id_replicationprotecteditem_test.go new file mode 100644 index 00000000000..79746b3b3a0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/id_replicationprotecteditem_test.go @@ -0,0 +1,417 @@ +package targetcomputesizes + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReplicationProtectedItemId{} + +func TestNewReplicationProtectedItemID(t *testing.T) { + id := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultName" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultName") + } + + if id.ReplicationFabricName != "replicationFabricName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationFabricName'", id.ReplicationFabricName, "replicationFabricName") + } + + if id.ReplicationProtectionContainerName != "replicationProtectionContainerName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectionContainerName'", id.ReplicationProtectionContainerName, "replicationProtectionContainerName") + } + + if id.ReplicationProtectedItemName != "replicationProtectedItemName" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicationProtectedItemName'", id.ReplicationProtectedItemName, "replicationProtectedItemName") + } +} + +func TestFormatReplicationProtectedItemID(t *testing.T) { + actual := NewReplicationProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "replicationFabricName", "replicationProtectionContainerName", "replicationProtectedItemName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicationProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestParseReplicationProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicationProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultName", + ReplicationFabricName: "replicationFabricName", + ReplicationProtectionContainerName: "replicationProtectionContainerName", + ReplicationProtectedItemName: "replicationProtectedItemName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationFabrics/replicationFabricName/replicationProtectionContainers/replicationProtectionContainerName/replicationProtectedItems/replicationProtectedItemName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + Expected: &ReplicationProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtNaMe", + ReplicationFabricName: "rEpLiCaTiOnFaBrIcNaMe", + ReplicationProtectionContainerName: "rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE", + ReplicationProtectedItemName: "rEpLiCaTiOnPrOtEcTeDiTeMnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtNaMe/rEpLiCaTiOnFaBrIcS/rEpLiCaTiOnFaBrIcNaMe/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRs/rEpLiCaTiOnPrOtEcTiOnCoNtAiNeRnAmE/rEpLiCaTiOnPrOtEcTeDiTeMs/rEpLiCaTiOnPrOtEcTeDiTeMnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicationProtectedItemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.ReplicationFabricName != v.Expected.ReplicationFabricName { + t.Fatalf("Expected %q but got %q for ReplicationFabricName", v.Expected.ReplicationFabricName, actual.ReplicationFabricName) + } + + if actual.ReplicationProtectionContainerName != v.Expected.ReplicationProtectionContainerName { + t.Fatalf("Expected %q but got %q for ReplicationProtectionContainerName", v.Expected.ReplicationProtectionContainerName, actual.ReplicationProtectionContainerName) + } + + if actual.ReplicationProtectedItemName != v.Expected.ReplicationProtectedItemName { + t.Fatalf("Expected %q but got %q for ReplicationProtectedItemName", v.Expected.ReplicationProtectedItemName, actual.ReplicationProtectedItemName) + } + + } +} + +func TestSegmentsForReplicationProtectedItemId(t *testing.T) { + segments := ReplicationProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicationProtectedItemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/method_listbyreplicationprotecteditems.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/method_listbyreplicationprotecteditems.go new file mode 100644 index 00000000000..2bff64e44bb --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/method_listbyreplicationprotecteditems.go @@ -0,0 +1,105 @@ +package targetcomputesizes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByReplicationProtectedItemsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TargetComputeSize +} + +type ListByReplicationProtectedItemsCompleteResult struct { + LatestHttpResponse *http.Response + Items []TargetComputeSize +} + +type ListByReplicationProtectedItemsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByReplicationProtectedItemsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByReplicationProtectedItems ... +func (c TargetComputeSizesClient) ListByReplicationProtectedItems(ctx context.Context, id ReplicationProtectedItemId) (result ListByReplicationProtectedItemsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByReplicationProtectedItemsCustomPager{}, + Path: fmt.Sprintf("%s/targetComputeSizes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TargetComputeSize `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByReplicationProtectedItemsComplete retrieves all the results into a single object +func (c TargetComputeSizesClient) ListByReplicationProtectedItemsComplete(ctx context.Context, id ReplicationProtectedItemId) (ListByReplicationProtectedItemsCompleteResult, error) { + return c.ListByReplicationProtectedItemsCompleteMatchingPredicate(ctx, id, TargetComputeSizeOperationPredicate{}) +} + +// ListByReplicationProtectedItemsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TargetComputeSizesClient) ListByReplicationProtectedItemsCompleteMatchingPredicate(ctx context.Context, id ReplicationProtectedItemId, predicate TargetComputeSizeOperationPredicate) (result ListByReplicationProtectedItemsCompleteResult, err error) { + items := make([]TargetComputeSize, 0) + + resp, err := c.ListByReplicationProtectedItems(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 = ListByReplicationProtectedItemsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/model_computesizeerrordetails.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/model_computesizeerrordetails.go new file mode 100644 index 00000000000..f16abf36733 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/model_computesizeerrordetails.go @@ -0,0 +1,9 @@ +package targetcomputesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeSizeErrorDetails struct { + Message *string `json:"message,omitempty"` + Severity *string `json:"severity,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/model_targetcomputesize.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/model_targetcomputesize.go new file mode 100644 index 00000000000..532ef19b568 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/model_targetcomputesize.go @@ -0,0 +1,11 @@ +package targetcomputesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetComputeSize struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TargetComputeSizeProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/model_targetcomputesizeproperties.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/model_targetcomputesizeproperties.go new file mode 100644 index 00000000000..474a614fb31 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/model_targetcomputesizeproperties.go @@ -0,0 +1,17 @@ +package targetcomputesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetComputeSizeProperties struct { + CpuCoresCount *int64 `json:"cpuCoresCount,omitempty"` + Errors *[]ComputeSizeErrorDetails `json:"errors,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HighIopsSupported *string `json:"highIopsSupported,omitempty"` + HyperVGenerations *[]string `json:"hyperVGenerations,omitempty"` + MaxDataDiskCount *int64 `json:"maxDataDiskCount,omitempty"` + MaxNicsCount *int64 `json:"maxNicsCount,omitempty"` + MemoryInGB *float64 `json:"memoryInGB,omitempty"` + Name *string `json:"name,omitempty"` + VCPUsAvailable *int64 `json:"vCPUsAvailable,omitempty"` +} diff --git a/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/predicates.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/predicates.go new file mode 100644 index 00000000000..e884ca4906e --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/predicates.go @@ -0,0 +1,27 @@ +package targetcomputesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetComputeSizeOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p TargetComputeSizeOperationPredicate) Matches(input TargetComputeSize) 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/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/version.go b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/version.go new file mode 100644 index 00000000000..a54bcff27f0 --- /dev/null +++ b/resource-manager/recoveryservicessiterecovery/2025-02-01/targetcomputesizes/version.go @@ -0,0 +1,10 @@ +package targetcomputesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-02-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/targetcomputesizes/2025-02-01" +}